web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Setting Default Closed...
Power Apps
Answered

Setting Default Closed Date according to the Status

(0) ShareShare
ReportReport
Posted on by 36

Hi,

 

In my app there is a gallery to display all tickets and then there is a view details page. If the user wants to edit it user has to click "Edit" button and then can go to edit form. In the edit form, there is a closed date field. I need to set that closed date according to the status. There is a drop down to select status. 

 

Scenario 1:

If the status of the ticket is new, by default closed date should be empty. If user changes status to Closed, then closed date should be set to current date. If changed again to new, then closed date should be empty.

 

Scenario 2:

If the status of the ticket is already closed, by default closed date should be that previously closed date, not current date. Then, If user changes status to new, closed date should be empty. If again changed to closed, closed date should be previously closed date.

 

In order fulfill this requirement, I added below statement to Default Date property of Date picker. 

 

Switch(
 IsClosedPreviously,
 true,
 If(
 IsStatusClosed,
 EditRecord.'Closed Date'
 ),
 false,
 If(
 IsStatusClosed,
 Today()
 )
)

 

 

IsClosedPreviously and IsStatusClosed variables are initialized in App OnStart property as below.

 

Set(IsClosedPreviously, false);
Set(IsStatusClosed,false);

 

 

Then, I set the values to these variables in OnSelect property of Edit Button of the View details page, that I mentioned above. I did that because I need to check whether it is closed or not before loading edit form. So, when clicking the edit button those variables will be set and then load the default closed date  according to those variables.

 

Onselect property of edit button is as below.

 

Set(IsClosedPreviously, If(EditRecord.Status.Value="Closed", true,false));
Set(IsStatusClosed,If(IsClosedPreviously, true, false));

 

 

In this way scenario 1 happens as I want. But Scenario 2 has an issue.

 

In scenario 2- At the first time I load the edit form, default date is set to current date. But in scenario 2 it should be previous closed date, not current date. when I go back and come again to the form, default date sets to previous date as I want. I want to do it without going back and come. 

 

please help me to solve this issue.

 

Regards,

Nipuni

 

Categories:
I have the same question (0)
  • Verified answer
    Nipuni Profile Picture
    36 on at

    Hi all,

    I solved this issue. In addition to the above codes, I added below statement to the OnSelect property of edit button.

    Set(ClosedDate,If(IsClosedPreviously,Record.'Closed Date'));

     

    Next changed the DefaultDate peroperty of Date Picker as below.

    Switch(
     IsClosedPreviously,
     true,
     If(
     IsStatusClosed,
     ClosedDate
     ),
     false,
     If(
     IsStatusClosed,
     Today()
     )
    )

     

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard