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 / Set date field in cust...
Power Apps
Answered

Set date field in custom form when another field is changed to certain value

(0) ShareShare
ReportReport
Posted on by 59

Hi.  I am transitioning our SharePoint from InfoPath to a PowerApps custom form.  One thing I'm still struggling with is implementing a rule in my custom form that I had in the InfoPath form. 

 

The rule was if my Status field = "Closed" set my ClosedDate field to Now().  I then had a second rule that said if my Status field = "Open" set my ClosedDate field to "".

 

I tried putting this in the default for my ClosedDate field:  If(DataCardValue21.Selected.Value="Closed",Now(),"")

 

That works but of course if we open an existing closed item, it updates the date to today.  This date should only populate or update if we change the selected value in the status field to Closed.  And if it's set to Open, it needs to clear the date out.

 

I'm guessing I need something in the Status onChange property but not quite sure what.  I appreciate some advice.  Thank you!

Categories:
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @lottidah 

    Please try the following,

    If(DataCardValue21.Selected.Value="Closed" && ThisItem.Status<>"Closed",Now(),"")

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • lottidah Profile Picture
    59 on at

    Thanks for the response.  I'm not sure how to do this.  Does this still go in the default for the ClosedDate field?  If so, "ThisItem.Status<>"Closed" doesn't work since it is a date field.

     

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @lottidah Does this still go in the default for the ClosedDate field? Yes

    remove the " before ThisItem

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • lottidah Profile Picture
    59 on at

    That was just poor editing on my message.

     

    It doesn't like the <>.

     

    lottidah_0-1682614439963.png

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @lottidah If the field is Status, the it should be ThisItem.Status.Value

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • lottidah Profile Picture
    59 on at

    I thought this was it but, for items that were set to "Closed" and the ClosedDate was populated, when you bring them back up in the form the ClosedDate field is blank.  It should display the date that was already set.

     

     

  • lottidah Profile Picture
    59 on at

    To clarify: 

     

    There is a Status field with two choices:  Open and Closed.  The default for this field is Open.  If someone selects "Closed" it should update the ClosedDate field with today's date.  If the item was already set to Closed and then moved back to Open, it should clear the date from the ClosedDate field.  Items that were already closed and already have a date populated in the ClosedDate field should retain that date unless the Status field is changed back to Open.

     

    This was super easy in InfoPath rules.  

     

    The solution above is almost there, but existing closed items are showing a blank date when loaded into the form.

  • CindyZ Profile Picture
    on at

    @lottidah Did you ever find a solution to this.  I can't believe how difficult this small thing is and I've not been able to find an answer.

  • Verified answer
    lottidah Profile Picture
    59 on at

    Hi, yes I did finally get this working after much trial and error.  

     

    In the OnChange property for the Status field, I put:

    Reset(DataCardValueClosedDate)

     

    In the DefaultDate property for the ClosedDate field, I put:

     

    If(DataCardValueStatus.Selected.Value="Closed" && ThisItem.Status.Value<>"Closed",Now(),If(DataCardValueStatus.Selected.Value<>"Closed","",Parent.Default))

     

    Hope that helps.

  • CindyZ Profile Picture
    on at

    @lottidah Love the name!  Also, thanks so much for your response.  It is much appreciated! 

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard