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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I update a vari...
Power Apps
Unanswered

How do I update a variable when UpdateContext is triggered?

(0) ShareShare
ReportReport
Posted on by 634

Here is what I have. 

 

3rd_party_powerapps.png

 

When a user chooses ** Add 3rd Party ** from the 3rd Party combobox the "Add 3rd Party" text field appears. When they click the "Add" button the following executes: (NOTE: DefaultSelectedItems is set too newThird)

 

 

If(!IsBlank('Add 3rd Party TB'.Value),UpdateContext({newThird:Patch('Third Parties', {'Third Party (cr9c7_thirdparty)':'Add 3rd Party TB'.Value})});Reset('Add 3rd Party TB'))

 

 

This works great but I have found a problem I am trying to solve. Instead of referencing the value of the combobox for later use as below

 

 

 

 

'3rd Party CB'.Selected.'Third Party (cr9c7_thirdparty)'

 

 

 

 

I decided to assign the value of the combobox to a variable at OnChange like this for easier reference.

 

 

 

 

Set(source3rd,'3rd Party CB'.Selected.'Third Party (cr9c7_thirdparty)')

 

 

 

 

This works great IF I am changing the value manually. When the combobox value is updated with UpdateContext then the OnChange function is not triggered. Is there a way to make this work or perhaps my whole approach needs a rework.

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Future_Vision 

    If I understand it right, https://powerusers.microsoft.com/t5/Building-Power-Apps/Trigger-a-dropdown-OnChange-from-a-button/m-p/632168#M200421 may be the solution to your question.  Basically store the action in the button and have the OnChange select the button. 

  • Future_Vision Profile Picture
    634 on at

    Hmmm. Not completely sure I understand. I got this to work but there may be a better way. 

     

    1. DefaultSelectedItem is set to newThird. This allows the combobox to choose the value I entered in the "Add 3rd Party" textbox when it refreshes after the Patch.
    2. I left the OnChange property of the 3rd Party combobox set to update source3rd when a change is made unless it is the "** Add 3rd Party **" option
    3. On the button. I set source3rd to the value of the Add 3rd Party textbox.

    This allows a value to be written to source3rd when the dropdown is selected and then overwritten if a new value is added. Again, not sure this is the most efficient way to do this though. Perhaps @Drrickryp 's solution is better. I'm just unsure how to implement that.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 321 Super User 2026 Season 1

#2
WarrenBelz Profile Picture

WarrenBelz 289 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 200 Super User 2026 Season 1

Last 30 days Overall leaderboard