web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Context variable not u...
Power Apps
Unanswered

Context variable not updating OnChange

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

 

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({
 IHour:HourPicker1.Selected.Value,
 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? 

 

Categories:
I have the same question (0)
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    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 

    HourPicker1.Selected.Value

    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

    Regards,

    Michael

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard