cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
seadude
Level 10

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
Super User
Super User

Re: Help Understanding Set() and UpdateContext({})

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

Re: Help Understanding Set() and UpdateContext({})

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
Super User
Super User

Re: Help Understanding Set() and UpdateContext({})

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

Re: Help Understanding Set() and UpdateContext({})

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

seadude
Level 10

Re: Help Understanding Set() and UpdateContext({})

Hi @KeithWhatling 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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 319 members 5,580 guests
Please welcome our newest community members: