cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Memorable Member
Memorable Member

Help Understanding Set() and UpdateContext({})

Hello,
I keep running into this silly issue. Could use some help understanding it.

Issue:

  • There are times when I use Set(var,Blank()) on Screen1, then move to Screen2 and var does NOT update.
  • In these cases, var is black color in the Function Bar on Screen1 and a blue color in the Function Bar on Screen2.
  • Since the var will not set, I have to delete it and change it to UpdateContext({var:true}) on Screen2 in order for things to work.

Why? I thought that if I declare a var with Set(), its scope is universal. Why am I getting hung up here?

Thank you

2 ACCEPTED SOLUTIONS

Accepted Solutions
wyotim
Resident Rockstar
Resident Rockstar

That is odd indeed. Have you tried looking at the Global Variables section and looking at the Definitions, Uses, and Indirect Uses? That would help in tracking the places that could be calling it, just to ensure it isn't being called somewhere unexpected. Otherwise, something strange is going on as I am pretty sure Set is global in scope.

View solution in original post

Anonymous
Not applicable

Just to clarify that a veriable declared with Set called var and a variable declared with UpdateContext called var will be two different variables.

 

You cannot change a Set() global vairable with a local UpdateContext({}) call.

 

Recomendations from the coding guidlines suggest that global variable names get a glo prefex and locals get a loc prefex so a Set() variable called var becomes gloVar and a local UpdateContext becomes locVar.

 

Hope this helps.

 

View solution in original post

3 REPLIES 3
wyotim
Resident Rockstar
Resident Rockstar

That is odd indeed. Have you tried looking at the Global Variables section and looking at the Definitions, Uses, and Indirect Uses? That would help in tracking the places that could be calling it, just to ensure it isn't being called somewhere unexpected. Otherwise, something strange is going on as I am pretty sure Set is global in scope.

Anonymous
Not applicable

Just to clarify that a veriable declared with Set called var and a variable declared with UpdateContext called var will be two different variables.

 

You cannot change a Set() global vairable with a local UpdateContext({}) call.

 

Recomendations from the coding guidlines suggest that global variable names get a glo prefex and locals get a loc prefex so a Set() variable called var becomes gloVar and a local UpdateContext becomes locVar.

 

Hope this helps.

 

Hi @Anonymous and @wyotim, I now understand the areas you brought up. Thanks for the best practices of looking at "uses" and the glo and loc prefixes. Thats good stuff.

I was missing the part that Set(varThing,true) and UpdateContext({varThing:true}) are SEPARATE VARIABLES even though they are allowed to be named the same.

 

 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,359)