cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Global Variable / Multiple Condition Statement

I have the following variables set:

 

Set(varIsHierarchyEmployee,"Employee");
Set(varIsHierarchyPark,"Park");
Set(varIsHierarchyRegion,"Region");
Set(varIsHierarchyNational,"National");

 

I have many screens that resemble the functionality of the one below. I would like to restrict access to the Dropdowns/Combo Boxes, and the information filtered/displayed in said Dropdowns/Combo Boxes and any Galleries on the screen.

 

Example (UserName is being pulled from the active directy):

1. Park Dropdown has ComboBox2.Selected.Park in the default (pulling the default location of the User from a main screen combo box. I currently have If(varIsHierarchyEmployee=true, DisplayMode.Edit,DisplayMode.Disabled) in the DisplayMode. The User in the example does have a hierarchy of 'Employee'.

2. Region Dropdown populates based on the content of the Park Dropdown.

3. The Gallery Items is set to Filter(LocationDetailList, Park=LocationParkDD.Selected.Park)

4. What I'd like to do is install a global variable, condition, formula that will do the above on every page automatically.

 

Is this possible?

 

 

Screen.PNG

5 REPLIES 5
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

if you want to Use global variable on every page then use your code into AppLoad and Use where you want to use /any screen.

Thanks,
Vijay

denglish
Advocate II
Advocate II

Using Set() creates or updates a global variable, corresponding to the variable name passed in the first parameter. This is in contrast to UpdateContext(), which allows for creating and updating context variables, scoped to the screen where the method is invoked.

 

I would echo the first commenter and recommend establishing these variables in the OnStart attribute of the App object:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/object-app

 

denglish_0-1602619311597.png

 

The App object is at the top of the Tree View list.

Anonymous
Not applicable

Yes, thank you. 

 

All of the variables I've shown I have created and have in place in the App/OnStart.

 

My issue is where and how to apply each in each screen for the dropdowns, combo boxes, and galleries.

Hi @Anonymous ,

Now you can use the Variable on the screen you want to see the value like the same way you are using previously.

See the demo for reference- Please Find attached the File for Demo reference - 

Thanks,



Maybe put the conditions in the OnStart as well.

 

Set(DropdownDisplayMode1, <condition1>, DisplayMode.Edit, DisplayMode.Disabled);

Set(DropdownDisplayMode2, <condition2>, DisplayMode.Edit, DisplayMode.Disabled);

...

 

Then you can assign your DisplayMode variable to the DisplayMode attribute of the dropdowns on each screen.

 

Alternatively, you might benefit from using a Component Library, if the dropdowns behave the same on each screen, depending on how they interact with your Data Sources.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,700)