Power Apps Variables: Global vs. Context and what you need to know

  Рет қаралды 30,345

Shane Young

Shane Young

Күн бұрын

Пікірлер: 53
@sam-adjei
@sam-adjei 2 жыл бұрын
Hi Shane, Great refresher. One tip I would add (for folks who are not color blind), Global variable names show up in green when referenced and context variable names show up in blue :)
@ShanesCows
@ShanesCows 2 жыл бұрын
Thanks for sharing Sam.
@brendanbowen7097
@brendanbowen7097 2 жыл бұрын
Hey Shane, Great video refresher on global vs context variables. One trick I have been using regarding context variables if I really need it's value on a different screen and don't want to use a global: passing a context variable to another screen using the navigate function. I had a scenario where I needed to pass a month value from a dropdown to another screen that also had a month dropdown dialog box so the user would have that month already selected on that screen. Navigate(‘Screen2’,None,{varSelectedMonth: dropdown1.selected.value}) - the navigate function allows us to pass one or multiple context variables to another screen.
@ShanesCows
@ShanesCows 2 жыл бұрын
Thanks for sharing Brendan! 🐶
@vidabailey16
@vidabailey16 Жыл бұрын
Just made my day!! Been suck and I could tell I needed a variable but wasn't sure how, and boom, I'm fixed! Thank you!
@ShanesCows
@ShanesCows Жыл бұрын
Awesome 🤩
@GroverParkGeorge
@GroverParkGeorge Жыл бұрын
I now prefix variables as gvarName for globals and cvarName for context variables. No more broken brain cells.
@ShanesCows
@ShanesCows Жыл бұрын
I like it :)
@taaee
@taaee 2 жыл бұрын
Shane, very clear! Thanks a lot for sharing your knowledge!
@ShanesCows
@ShanesCows 2 жыл бұрын
My pleasure!
@cbtjoe
@cbtjoe 2 жыл бұрын
I feel you made this just for me! Thanks Shane! :-)
@ShanesCows
@ShanesCows 2 жыл бұрын
I did Joe. I knew you were looking for this. 😁
@cvkealey
@cvkealey 2 жыл бұрын
We should start a support group: GVA (Global Variables Anonymous). I used to use the heck out of them because I thought I needed to. Nowadays, I typically use record variables (e.g.: Set(varO365Prof, Office356Users.UseProfileV2(User().Email))) and then reference components of that record as needed throughout the app. This works great for user profiles, items from galleries, etc. and helps cut down some of the chatter back and forth. Also, a naming convention is important. Use what works for you, but I always use the prefixes "var" for global and "ctx" for context variables.
@ShanesCows
@ShanesCows 2 жыл бұрын
I love that you have thought all of this out Chad. 🙂
@jeanpierreragequit1726
@jeanpierreragequit1726 2 жыл бұрын
Great video Shane !! Thx a lot
@ShanesCows
@ShanesCows 2 жыл бұрын
My pleasure!
@oluwatobiyusuf
@oluwatobiyusuf 2 жыл бұрын
Thank you so much Shane. New knowledge learnt
@ShanesCows
@ShanesCows 2 жыл бұрын
Awesomeness 🐶
@arielreina6221
@arielreina6221 2 жыл бұрын
Hi man, awesome video, excellent information!
@ShanesCows
@ShanesCows 2 жыл бұрын
Thank you so much Ariel. I hope you have a great day - Grant :] (Shane's kid helping with the responses) 😎 🐶
@TheKermit2110
@TheKermit2110 2 жыл бұрын
Hi Shane - great vid, thanks. Another cool feature of context variables is they can be initiated on screen navigation (i.e. created on Screen1 but utilised in the screen being nav'd too). One thing i also would love to get a better understanding of is use of Variables in storing whole tables of records - i know this is what Collections are for (another variable type) but i'm pretty sure you can also do this in glb variables (not sure on Context variables tho). Cheers again
@ShanesCows
@ShanesCows 2 жыл бұрын
Yeah, I think you can store tables in regular variables but just seems like chaos so I have never messed with it. :)
@jamesbuchanan407
@jamesbuchanan407 Жыл бұрын
Thanks for the overview.
@ShanesCows
@ShanesCows Жыл бұрын
Happy to help
@hokemspitter
@hokemspitter Жыл бұрын
Hi Shane, I am struggling with how to set a global variable when the app first loads. I have a boolean variable (varShowInfo) that I use as the value of a label's visible property. The variable needs to start always with the value false. I have tried placing a Set(varShowInfo, Boolean(false)) in many places to no avail. I put it in the App OnStart event, but that only seems to execute if in the treeview, I select the ellipsis for App and click RunOnStart. That would be fine if it ALWAYS ran the OnStart when the App is started. Any help on this would be greatly appreciated. Great videos! Thanks
@dwolfe
@dwolfe 2 жыл бұрын
Hi Shane, is it possible to add a global variable so that a button on the main screen is hidden, until say, three other screens are visited?. I tried adding a global variable to onvisible for the secondary screens, but nadda. :(
@ShanesCows
@ShanesCows 2 жыл бұрын
Sure. I would set(varScreen1, true) on screen 1 OnVisible. Then repeat for screen 2 and 3. Then set the first button Visible property to varScreen1 And varScreen2 And VarScreen3 like that. It will show when all 3 are true.
@dwolfe
@dwolfe 2 жыл бұрын
@@ShanesCows You sir, are a legend! Thank you. I was doing this in reverse and pulling my hair out!
@franknielsen3219
@franknielsen3219 2 жыл бұрын
Really nice review of the world of variables. And you are the one to blame for me not using contextual variables 😂😂😂😂😂😂
@ShanesCows
@ShanesCows 2 жыл бұрын
Frank you are in good company. No one likes context variables. 😂
@zainraza1965
@zainraza1965 9 ай бұрын
Hi Shane, Thanks so much for providing information and tips regarding variables. I have a question. So basically what i want to do is create a form where the user will input information in various screens. So screen 1, they will enter information, then screen 2 they will enter information and keep going upto screen 5. Now what i want to do is take all those entered information and store it into a file as a single row item in Excel. This is ROW 1 items. Then a new user comes in enters new information and then this creates ROW 2 data in the same file. I searched around and got help from CHAT GPT, it said to do it using Variables and store information in variables and use it to export data into excel. Could you Shed some light into this scenario, or if you could help me out that would be greatly appreciated. Thank you.
@jodznolasco
@jodznolasco 2 жыл бұрын
Hi shane , I wonder if you could help me.. I have a dropdown with onchange value "UpdateContext( { varwl: 1 } )", -it helps me detect if there's a change then if the user submits a button, with "UpdateContext( { varwl: 0 } )" - resetting it back to zero it is not working very well, sometimes it work sometimes not,,,,it seems weird,,,escpecially when I get back to edit mode ,varwl still display 1 even if i hit the button which should be reset to 0. any thought?
@chriszielazny9855
@chriszielazny9855 2 жыл бұрын
Do you need to reset the context variables (set them to blank) if you are leaving the screen and then you want to come back to the same screen again, or will they reset themselves?
@ShanesCows
@ShanesCows 2 жыл бұрын
They will not automatically reset, you will need to reset them if you want them to be blank when you come back to the screen.
@charlessexton1483
@charlessexton1483 2 жыл бұрын
Microsoft recommend prefixing local variables with loc and global variables with gbl. I think it's a really good idea. Having them both as var is a bit dangerous, imo. Fine for small apps, but might cause confusion in a big app.
@ShanesCows
@ShanesCows 2 жыл бұрын
Agree Charles. For me old habits die hard. :)
@devinemichae
@devinemichae 2 жыл бұрын
Thank you Shane, most of what I have learned I have learned from you and Reza. I am definitely interested in Power Platform University.
@ShanesCows
@ShanesCows 2 жыл бұрын
Awesome. If you have questions about university feel free to shot me an email. shane at powerapps911 dot com 😁
@davej9787
@davej9787 11 ай бұрын
Great video!
@damianjohnson4945
@damianjohnson4945 2 жыл бұрын
Thanks Shane - another great vid. Is it possible to use this global variable to change all of the app font size?
@ShanesCows
@ShanesCows 2 жыл бұрын
You would have to set all of the controls in the app Size property to the value of the variable and then yes.
@parranoic
@parranoic 2 жыл бұрын
Shane I have a lot of issues with powerapps lately. Code missing from live app but features still available on embedded version, ui elements (like the gallery control) moved on the x axis on most of the screens of my app, even on apps I haven't touched for months. Even if i place them correctly, save, publish still the same next time I open the app. I tried reaching out to power app devs but nothing so far. Any idea what happen ?
@ShanesCows
@ShanesCows 2 жыл бұрын
Hey Don - I have not seen anythign like that. 😬 Hopefully it has gotten better. Sorry, that is annoying.
@matt-ayres-tech
@matt-ayres-tech Жыл бұрын
How do you set global variables on start-up, rather than tying them to buttons?
@ShanesCows
@ShanesCows Жыл бұрын
Look in the tree view for the App object. It has a property called OnStart. Put your code there.
@ShanesCows
@ShanesCows Жыл бұрын
I have a video that shows it here kzbin.info/www/bejne/bX7biaB9hNCYgrM
@khargos7602
@khargos7602 2 жыл бұрын
It's okay context variables...I'm here for you. 👨‍💻
@ShanesCows
@ShanesCows 2 жыл бұрын
You are too nice Khar. #TeamGlobalVariables
@geralddahl9159
@geralddahl9159 2 жыл бұрын
You often say not to reference gallery1.selected but to store the reference as a variable instead. What would that variable look like? (Link to video?) Thx for the helpful Blank() tip!
@geralddahl9159
@geralddahl9159 2 жыл бұрын
eg Set(varRecord, {FirstName: GERALD, LastName: DAHL})
@geralddahl9159
@geralddahl9159 2 жыл бұрын
eg (two rows) eg Set(varRecord, {FirstName: GERALD, LastName: DAHL},{FirstName: RICHARD, LastName: DAHL})
@ShanesCows
@ShanesCows 2 жыл бұрын
Set(varRecord, ThisItem) covered in this video. kzbin.info/www/bejne/bGqUoYWvh62KeLc
@geralddahl9159
@geralddahl9159 2 жыл бұрын
@@ShanesCows excellent, thx!!!
Power Apps Responsive Design
30:11
Shane Young
Рет қаралды 37 М.
Intro to PowerApps Variables
19:23
Shane Young
Рет қаралды 206 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Named Formulas & User Defined Functions in Power Apps
13:41
Reza Dorrani
Рет қаралды 47 М.
Use HTML Gradients and Styling to improve your Power Apps UI
21:26
5 Power Apps Best Practices for Early Makers
13:24
Shane Young
Рет қаралды 19 М.
Power Apps Collections Introduction
18:48
Shane Young
Рет қаралды 101 М.
Variables in Power Apps
18:15
Dhruvin Shah
Рет қаралды 19 М.
Power Apps Variables - All 5 Types
30:11
Shane Young
Рет қаралды 14 М.
Don't use PowerApps Gallery Selected Item
12:44
Shane Young
Рет қаралды 17 М.
Power Apps: When to Use Set or UpdateContext
6:33
April Dunnam
Рет қаралды 52 М.
Variables in Power Apps
17:08
Dhruvin Shah
Рет қаралды 103 М.
Top 25 Power Apps Tips, Tricks & Best Practices for Makers
26:57
Reza Dorrani
Рет қаралды 77 М.