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

Reset Date Based on Dropdown Selection

I am new to Powerapps and am trying to create a simple In/Out board to track where employees are. I started with a SharePoint list and am now editing the form in Powerapps. The two main fields are "Status", which is a dropdown that includes options like "In", "Out", "Appointment", etc., and a field called "Return Time" which allows them to select a date and time that they expect to be back in the office.

 

The simple thing I'd like to do is just reset the "Return Time" field to be blank whenever a new status is selected because I don't want a return date listed if their status is "In".

 

If I can get even fancier, I would want the "Return Time" field to be blank when "In" is selected from "Status", and I would want it to be set to tomorrow at 8am if "Out" is selected, and I would want it to be set to 1 hour from now if "Appointment" is selected.

 

The real kicker is that I still want the user to be able to change the date and time after this. For example, if a person changes their status to "Out" it would change the date and time to the next day at 8am, but the employee may not be coming in until the next day, or maybe not until 9am, so I would want them to be able to adjust the date and time still.

1 ACCEPTED SOLUTION

Accepted Solutions
jesperse
Level: Powered On

Re: Reset Date Based on Dropdown Selection

For my purposes I didn't actually need the date saved in as a date data type, so I ended up creating a new text field and used date and time pickers to update the text field. If I wanted it blank I told it to set the text field to null. For whatever reason PowerApps won't let you set a date to null.

 

Thanks for your suggestion!

2 REPLIES 2
Super User
Super User

Re: Reset Date Based on Dropdown Selection

You could try creating a "ReturnTime" variable in the OnVisible property of the screen and then set the variable to the current value of the actual Return Time. Then you would use that variable in the default setting of the Return Time field. Then in the OnChange event of the drop down you could change the value of the "ReturnTime" variable which should change the value being display in the Return Time field. When the form is saved it should save the value being displayed in the Return Time field.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
jesperse
Level: Powered On

Re: Reset Date Based on Dropdown Selection

For my purposes I didn't actually need the date saved in as a date data type, so I ended up creating a new text field and used date and time pickers to update the text field. If I wanted it blank I told it to set the text field to null. For whatever reason PowerApps won't let you set a date to null.

 

Thanks for your suggestion!