Showing results for 
Search instead for 
Did you mean: 
Resolver I
Resolver I

Context variable not updating OnChange


I'm running into an issue where the Date/Time that I'm generating `ITime` is correctly displayed in Label1.Text when the screen shows up (OnVisible), but when changing dropdowns, from say 8:00pm to 4:00pm, ITime doesn't update until the 2nd time it's changed, back to 3:00pm, ITime = 4:00pm (previous change).



Screen1.OnVisible = UpdateContext({
IDate: DatePicker1.SelectedDate,
IHour: HourPicker1.Selected.Value,
IMinute: MinutePicker1.Selected.Value,
IAMPM: AMPMPicker1.Selected.Value,
ITime: IDate & " " & IHour & ":" & IMinute & " " & IAMPM

Label1.Text = ITime


ITime = 4/25/2018 8:00 PM


HourPicker1.OnChange = UpdateContext({
  ITime: IDate & " " & IHour & ":" & IMinute & " " & IncidentDateAMPM.Selected.Value

Label1.Text doesn't change until DatePicker1 is changed a 2nd time.


ITime = 4/25/2018 8:00 PM (OnVisible)
ITime = 4/25/2018 8:00 PM (HourPicker1 changed to 4:00 PM)
ITime = 4/25/2018 4:00 PM (HourPicker1 changed to 3:00 PM)

ITime = 4/25/2018 3:00 PM (HourPicker1 changed to 9:00 PM)


It's acting like it's a step behind updating ITime? 


Community Support
Community Support

Re: Context variable not updating OnChange

I think that is the way how it works.

OnChange property would trigger the event when users trying to change the Dropdown Value, and please note it, the formula runs before the value changes was done, not after it.

So when the commands executing, the 


Keeps the previous value.


If you would like to keep the current value, then please just use the 

DatePicker1.SelectedDate&" "&HourPicker1.Selected.Value&": "& MinutePicker1.Selected.Value & " "&AMPMPicker1.Selected.Value




Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Resolver I
Resolver I

Re: Context variable not updating OnChange

Thank you Michael! 

The issue was actually that ITime can't be generated in the same UpdateContext() formula. I just did a new UpdateContext() on the next line and it worked as expected.

Helpful resources

Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,795)