web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Global Variable / Mult...
Power Apps
Unanswered

Global Variable / Multiple Condition Statement

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
  • Vijay Tailor Profile Picture
    2,961 on at

    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 Profile Picture
    128 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

  • Vijay Tailor Profile Picture
    2,961 on at

    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,



  • denglish Profile Picture
    128 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard