cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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
Highlighted
Dual Super User III
Dual Super User III

Hi @Phu_Le 

 

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
Highlighted
Dual Super User III
Dual Super User III

Hi @Phu_Le 

 

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!
Highlighted

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

Highlighted
Dual Super User III
Dual Super User III

Hi @Phu_Le 

 

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

Highlighted

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,509)