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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,442)