i have a datacard with the date picker and time controls. I can set the default of the datacard to Now() and it will populate the date and time with no issues. however i dont want the default to be now() as everytime i edit a record it will default to now() and not the date and time that was orignially selected in the record.
So how to i use a button to update the date and time datacard?
Solved! Go to Solution.
Here are the steps to do this.
Add a button and set the OnSelect property to this formula:
Unlock your data card and change the default property of the text input control to the formula shown beneath. Modify the value of the second argument so that it refers to your data item.
If(IsBlank(DateNow), ThisItem.EndDate, DateNow)
Select your screen and set the OnHidden property to this:
You should now be able to use the button to set the date.
so the more i tested this i have come to the conclusion that its not working as intended. As i originally stated my datacard is made up of the date picker and a drop down for both hour and minute.
I can set the data card no problem to now() and it "updates" the datepicker and hour and minute dropdowns. However it seems that the actual date and time values do not get stored in the hourvalue, minute value, and datevalue fields. So when i save it doesnt actualy save the now() date and time.
That sounds strange. If you were to update the hour and minute values manually (rather than using the now button), and to then save the record, does the form save the new value successfully to the data source?
yes it is strange. if using your scenario as soon as i navigate away from that screen and return it goes blank.
if i try and have a button on another screen to Set(vardate,now()) it also updates the card however it does not update the values as once i navigate away from that screen and return it is blank as well
Leaving the default to thisitem.date for the datacard and manually using the datepicker and dropdowns to time work as expected.
I am making a little progress but not using the button. I can set the default of the card to
and it retains the date values for the picker and dropdowns when changing screens.
Still unsure of what appears to be a simple task to update a date/time card with a now button. And further thought it should be able to update it if the card its populated or not.
One button click to set date time is much easier than 4 button clicks to set datepicker, time and minute.
Your solution works perfectly.
My problem is that I have 2 fields with a DateValue. I do not want both to be set to Now when a button is pressed. Do you have a solution?
I've used your button to change date. When used the button also changes colour and text. How do you do to make the button keep this colour and text? Now the button changes back to original colour and text the next time you open the app.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!