cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Update date picker values in an if statement

For context, I am building an app to record my shift hours during the week. I have made a dialog, to prompt if the start time and end time are match my usual schedule, based on the day of the week.

 

Screen 1: Dialog on BrowseScreen1

 

Screen Shot 2021-01-19 at 8.07.03 PM.png

 

 

So far I have programmed the Yes button to close the popup and go to EditScreen1(Form where I enter the data). I want an if statement inside the Yes button, to update the date and time values of EditScreen 1. Can someone advise how to accomplish this

 

For reference:

Screen 2: Edit Screen 1

 

 Screen Shot 2021-01-19 at 8.13.35 PM.png

5 REPLIES 5
Super User II
Super User II

Hi @m365newuser ,

My approach to your request:

set a global variable inside the OnSelect property of Yes button:

Set(isNormalShift,true)

And set then the default property of controls (my guess is this are dropdown boxes)

IN hour  to:

If(isNormalShift,"23",Hour(Now())) 

IN minutes:

If(isNormalShift,"00",Minute(Now())

OUT hour:

If(isNormalShift,"06",Hour(Now())) 

OUT minutes:

If(isNormalShift,"00",Minute(Now())

Also set the default date of Out DatePicker to:

If(isNormalShift,DateAdd(Today(),1,Days)

 

Hope it helps !

Hi @gabibalaban , I am new to Power Apps so please excuse any obvious things that I miss.

 

Can I ask how does your solution take into account the day of the week, my shift hours for each day varies. 

Secondly you mention to place (If(isNormalShift,"23",Hour(Now())) ) as default values, but I already have the default set to show the current date and time . I did this to save time selecting from the drop down and just straight away punching in the hours. Do I need to keep both or can your statement also display current time as an else statement 

@m365newuser ,

Well no .... Where do you keep your shift planning ? Is there a schema of your shift during the week ?

Regarding the second question formula  If(isNormalShift,"23",Hour(Now())) can be explained like this ...

If the user selected Yes button then show as default the "23", else show as default the now hour.

We have to get a logic off your shifts to create the schema.

 

@gabibalaban 

Again sorry I am new to power apps, when you refer to schema, should that be like a Sharepoint list or a screen in the app with the schedule detail. 

Could you guide with the logic for the shifts?

Frequent Visitor

Hello @WarrenBelz , would appreciate your advice or feedback

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (75,958)