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

Re: Auto set Date for DatePicker by condition

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

Re: Auto set Date for DatePicker by condition

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
Helper I
Helper I

Re: Auto set Date for DatePicker by condition

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

Re: Auto set Date for DatePicker by condition

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
Helper I
Helper I

Re: Auto set Date for DatePicker by condition

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
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,962)