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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / On Select change date ...
Power Apps
Unanswered

On Select change date value when drop down field change

(0) ShareShare
ReportReport
Posted on by 45

Community:

 

I have a form where I want to change the status of the record from open to close, when the status is changed in the form using a drop down menu, I want to then patch the date closed value to date now:

 

Here is the code as it stands:

 

If(Job_Status_Change_drp.Selected.Value = "Closed",
Patch( Gallery_Job_Status.Selected,ThisItem, { Close_Date: Now() }),ThisItem, { Close_Date:"" })

 

the source table is '[dbo].[aas_wf_transaction_tbl]'

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @WillieEra ,

    Try this

    If(
     Job_Status_Change_drp.Selected.Value = "Closed",
     Patch(
     ThisItem,
     {Close_Date: Now()}
     )
    )

    I am assuming ThisItem is correct.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up

  • WillieEra Profile Picture
    45 on at

    Thank you for the reply, I took your code but there seems to be an issue with the "ThisItem", so I changed it to the gallery.selected value and it shows no errors, however when I run it, the status changes from open to close but the date_close does not update the date to now()

     

    Here is the code:

    If(
          Job_Status_Change_drp.Selected.Value = "Closed",
          Patch(
                    Gallery_Job_Status.Selected,
                    {Close_Date: Now()}
       )
    )

  • WillieEra Profile Picture
    45 on at

    Been testing the code, my issue is record identifier, ThisItem does not work, tried Gallery.Selected, does not work.

    Any suggestions? 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Try

    If(
     Job_Status_Change_drp.Selected.Value = "Closed",
     Patch(
     {ID:Gallery_Job_Status.Selected.ID},
     {Close_Date: Now()}
     )
    )

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • WillieEra Profile Picture
    45 on at

    The IF statement works, I keep getting errors saying it cant identify the record to be patched, it seems to me the identifier is the issue in the statement, tried the now code, outcome the same.

     

    Appreciate the help.

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Ok @WillieEra ,

    Where are you running this code from - what type of control and where is it located - screen shot would help showing the control and the gallery.

  • eka24 Profile Picture
    20,923 on at

    I guess see what is missing from @WarrenBelz is the table name or Datasource: '[dbo].[aas_wf_transaction_tbl]'

    If I may ask it is a Gallery or a Form because in your initial question you said a form.

    In changing a record, the record must already exist in the datasource. But the dropdown="Closed" is yet to be submitted. 

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Thanks @eka24 ,

    Getting late here and I missed the obvious mistake I made at the start (typing off a tablet instead of testing).

    I will leave you to the solution with @WillieEra 

  • WillieEra Profile Picture
    45 on at

    To give more detail:

    It is a form.edit, the condition of the field is based on a drop down, the dropdown selects between ["Open","Closed"] when the user selects closed there is a date_close field that should default to Now(), so when Onselect FormSubmit I want to patch that condition into the close_date.

     

    The form gets selected from a previous screen from a gallery.

     

     

  • Verified answer
    eka24 Profile Picture
    20,923 on at
    If(Job_Status_Change_drp.Selected.Value = "Closed",
    Patch('[dbo].[aas_wf_transaction_tbl]', (Close_Date: "Closed"),{ Close_Date: Now() })

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard