cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Auto set Date for DatePicker by condition

Hi all,

I want to auto set date for DatePicker by If Like

if(A=B, Set(DatePicker.SelectedDate=Today()))

but it doesn't work. Can we SET date for Datepicker?

(I Still want to keep DefaultDate = Parent.Default for showing Parent.Default Date on Re-EditScreen). Thank!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous 

 

We don't have any such functionality in PowerApps to directly update a control's value. The expression that you want to use, basically does a comparison and returns a Boolean value, which is not needed in your case.
As a workaround, you can set separate values for different form modes, you can modify your expression as:
If(Form1.Mode = New, SelectedDatevar ,Parent.Default)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

4 REPLIES 4
yashag2255
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

You can create a variable either on App Start or Page "On Visible" property to check the condition and set the value.

Set(SelectedDatevar,If(A=B,Today(),Blank()))

Now, you can reference this variable in the "Default" property of your DatePicker.

Also, if you want to set this variable again on some action, you can use the same expression.
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Anonymous
Not applicable

Hi @yashag2255 

 

I don't want to create a variance in DefaultDate of DatePicker1, because of when I push at Re-Edit in DetailScreen, That Datepicker can't show the history date that corresponding to last or other Submit

 

In my case, I want DatePicker1 to show the today date when I click on button Negotiation

My code Onselect of Button: DatePicker1.SelectedDate = Now()

but it doesn't work friend, can we have another way to Auto Set Date for DatePicker?

Capture.PNG

Hi @Anonymous 

 

We don't have any such functionality in PowerApps to directly update a control's value. The expression that you want to use, basically does a comparison and returns a Boolean value, which is not needed in your case.
As a workaround, you can set separate values for different form modes, you can modify your expression as:
If(Form1.Mode = New, SelectedDatevar ,Parent.Default)
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Anonymous
Not applicable

Thank @yashag2255 

It totally solved my problem

I get many stuck when working with Powerapps, I will ask you more later. thank so much

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,577)