have a datepicker in the form that defaults to this Sunday of the week. If the user keeps this interface open, the default date will not change. If the user submits the form next week, the default date is still last Sunday. I just want to give the user a button to submit the form. How can I make the user refresh this default date automatically every time they submit, and set it to the Sunday date when the user submits? thanks.
Thanks. i think that will also do the trick, but let me try use veriable, it will update defaultdate too.
thanks. let me try this.
HI , @EricDa
If you always want to save the date after submitting the form as the Sunday of the time the user clicks the submit button. You can update this field:
DataCard - Update: (This determines what data you submit to the data source )
Today()-Weekday(Today(),StartOfWeek.Monday)+1+6
This way, no matter what the user chooses, the submission will always be the Sunday of the week on which the button is clicked.
If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance!
Best Regards,
Yueyun Zhang
thanks for reply, i have no problem with setting defaultdate of datepicker. as i mentioned, if today date is May 24, 2024, the defaultdate of datepicker is May 26, 2024. if user leave the app interface(form) open untill May 27, 2024, then submit the form on May 27, the defaultdate of datepikcer is still remain on May 26 which is not what i want. i also dont want to user to use resetform(), because user will lost all the fill in information in the form.
@EricDa ,
Set your defaultDate in datepicker to varDate
then on your submit button:
Set(varDate,
DateAdd(Today(),
With({
_sday:Weekday(Today(), StartOfWeek.Sunday)},
If(
_sday>=5, 8-_sday,1)),
TimeUnit.Days)
)
_____________________________________________________________________________________
Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!
thanks for your reply, the datepicker is in the form, i cannot use reset() to reset it. i can only insert a icon into that datacardcontrol and set icon.onselect to hold reset(). but i dont want to user to click the icon, i only want to use click the submitform button.
HI , @EricDa
According to your description, you want to always add the Sunday in your side.
For example , this is my test data:
We need to use this expression:
DataCard - Default:
If(Form1.Mode= FormMode.New ,Today()-Weekday(Today(),StartOfWeek.Monday)+1+6 , ThisItem.WeekStart)
DataCard - Update: (This determines what data you submit to the data source )
Today()-Weekday(Today(),StartOfWeek.Monday)+1+6
Button- OnSelect:
SubmitForm(Form1);ResetForm(Form1);
If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance!
Best Regards,
Yueyun Zhang
hey @EricDa
can u try this in the default of date picker
DateAdd(Today(), 7 - Weekday(Today()), Days)
and this in button onselect:
Reset(NextSundayPicker);
SubmitForm(YourFormName); // Replace 'YourFormName' with the actual name of your form if you're submitting a form
Let me know if my answer helped solving your issue.
If it did please accept as solution and give it a thumbs up so we can help others in the community.
Greetings