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
Super User
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!
4 REPLIES 4
Super User
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!
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

Super User
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!
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
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 480 members 4,456 guests
Please welcome our newest community members: