I have a form with two date pickers. I'd like to save it as a global variable after selecting a date in date picker 2. Then, after saving the form, I would like the saved date in the new form to be set as the default value for date picker 1. I tried the following codes in on change for data picker 2:
"Set(ChangedDose; DataCardValue50.SelectedDate)"
and also the following code for the default on date picker 1:
"ChangedDose"
I assigned the save record button to the following code on select:
"SubmitForm(Form1);;Refresh('Data1');;UpdateContext({resetdate: true});;UpdateContext({resetdate: false})"
Reset for both date pickers is set to local variable "resetdate".
Unfortunately, when selecting a date, the global variable is not saved correctly and the blank value is returned with the date type.
Solved! Go to Solution.
This is all best done in your OnSuccess action of your form.
Your Formula for submitting the for should ONLY ever be: SubmitForm(Form1)
A form submits asynchronously, so it immediate performs the functions after your submitform, even before the form has submitted. So changing the form or deriving anything from it during that phase is not guaranteed to accurate.
Your OnSelect of your save record button should be: SubmitForm(Form1)
Your OnSuccess action Formula on the form should be:
Set(ChangedDose; Self.LastSubmit.fieldNameForDatepicker);;
UpdateContext({resetdate: true});;UpdateContext({resetdate: false})
Note: refreshing the datasource is not needed and will only slow your app. The data you submitted will all be in the datasource already.
In the above, change the field name to the field that contains the date from DatePicker 2.
Get rid of the OnChange formula for the datapicker.
You can keep your DefaultDate on the other date picker as ChangeDose
I hope this is helpful for you.
This is all best done in your OnSuccess action of your form.
Your Formula for submitting the for should ONLY ever be: SubmitForm(Form1)
A form submits asynchronously, so it immediate performs the functions after your submitform, even before the form has submitted. So changing the form or deriving anything from it during that phase is not guaranteed to accurate.
Your OnSelect of your save record button should be: SubmitForm(Form1)
Your OnSuccess action Formula on the form should be:
Set(ChangedDose; Self.LastSubmit.fieldNameForDatepicker);;
UpdateContext({resetdate: true});;UpdateContext({resetdate: false})
Note: refreshing the datasource is not needed and will only slow your app. The data you submitted will all be in the datasource already.
In the above, change the field name to the field that contains the date from DatePicker 2.
Get rid of the OnChange formula for the datapicker.
You can keep your DefaultDate on the other date picker as ChangeDose
I hope this is helpful for you.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
183 | |
45 | |
45 | |
34 | |
34 |
User | Count |
---|---|
257 | |
82 | |
78 | |
67 | |
65 |