cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LRio
Frequent Visitor

DateTime Picker Static Value or How to create a simple time stamp

Hello

I am creating an app that based on the dropdown value it will populate todays date on a date time picker, but if the value on the dropdown is not equal to "On Hold" it should either display the Parent Default or blank. The problem using Today() to set the datetime picker is that on the next day the value will change and I need this date value to be static until the user changes the dropdown

 

Code on Dropdown:

OnSelect: If(DataCardValue15.Selected.Value = "On Hold",UpdateContext({HoldVar:Today()}),DataCardValue15.Selected.Value <>"On Hold",UpdateContext({HoldVar:Blank()}));

 

Code on Date time picker

DefaultDATE: If(DataCardValue15.Selected.Value = "On Hold",HoldVar2)

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @LRio,

Do you want to to display a static date value for Date Picker before the user changes the dropdown value from "On Hold" to other?

 

If so, I think you just need to save the logged date in a variable and assign it to the DefaultDate property of the Date Picker. 

 

Set the DefaultDate property of the Date Picker as below:

If(DataCardValue15.Selected.Value = "On Hold",HoldVar)

Dropdown OnSelect: 

If(DataCardValue15.Selected.Value = "On Hold",UpdateContext({HoldVar:Date(2021,12,21))}),DataCardValue15.Selected.Value <>"On Hold",UpdateContext({HoldVar:Blank()}));

 

Best Regards,
Qi

View solution in original post

4 REPLIES 4
Eelman
Super User
Super User

@LRio 

Try moving your code from OnSelect to OnChange

LRio
Frequent Visitor

i have tried the On change as well but If i do the On change, as soon as I enter edit mode it will bring in the current time. I just need a simple method to record a time stamp based on a dropdown. If "on hold" is selected then log todays date, else blank, but if i go back to the records it should display the logged date

@LRio 

Ok, but every time a user selects the dropdown when using OnSelect, your code will run. This is typically not ideal.

 

try this on your DefaultDate

 

If(DataCardValue15.Selected.Value = "On Hold",HoldVar2, Parent.Default)

 

You can also try using 

 

ThisItem.yourCoulmnNameHere

 

if the above doesn’t work

v-qiaqi-msft
Community Support
Community Support

Hi @LRio,

Do you want to to display a static date value for Date Picker before the user changes the dropdown value from "On Hold" to other?

 

If so, I think you just need to save the logged date in a variable and assign it to the DefaultDate property of the Date Picker. 

 

Set the DefaultDate property of the Date Picker as below:

If(DataCardValue15.Selected.Value = "On Hold",HoldVar)

Dropdown OnSelect: 

If(DataCardValue15.Selected.Value = "On Hold",UpdateContext({HoldVar:Date(2021,12,21))}),DataCardValue15.Selected.Value <>"On Hold",UpdateContext({HoldVar:Blank()}));

 

Best Regards,
Qi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,202)