cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Phu_Le
Level: Powered On

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

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

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
Phu_Le
Level: Powered On

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

Dual Super User
Dual Super User

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

Phu_Le
Level: Powered On

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,911)