


Select the Settings button and type the varIsProjectManager value into the Visible property. Now we will control the Settings button’s visibility with the varIsProjectManager variable. varUserEmail and varIsProjectManager are now updated with values.
SHOWHIDE OPTION CODE
Set(varIsProjectManager, varUserEmail = execute the code in OnStart for testing purposes, click on the three dots beside App and select Run OnStart. A match returns true and a non-match returns false. Then we check if varUserEmail matches the Project Manager’s email and save the result in the varIsProjectManager variable. The User function retrieves the current logged in user’s email and this value gets stored in the variable varUserEmail. Write this code in the OnStart property of the app. Include a red Settings button that will show/hide based on the current user. Open Power Apps Studio and create a new app that looks like the one shown below. If the hardcoded email ever needs to be changed we must edit and republish the app because the email address is hardcoded instead of being retrieved from a datasource.Ĭheck The Current App User’s Email Address This is the easiest option to show/hide a button but it has a disadvantages over the other options. When both emails addresses match the button will show and when they do not match the button will be hidden. The simplest way to show or hide a button based on the current user is to compare their email address to an email address hard-coded into the app and see if it matches. Option #1: Show/Hide Button If Current User Matches Hardcoded Email Employees should not have access to the Settings Screen. When an Employee who is not a Project Manager logs into the app the Settings button becomes hidden. Pressing this button will navigate the app to a screen that only the Project Manager should see. When a Project Manager is logged the app’s menu shows a settings button. The Project Tracker app is used by Project Managers and other employees at a construction company to manage locations, review works orders and create invoices.

Check The Azure AD Group For Current App User Option #3: Show/Hide Button If Current User Is In SharePoint List.Check The Current Apps User's Email Address Option #2: Show/Hide Button If Current User Is In Azure AD Group.Introduction: The Project Tracker App Option #1: Show/Hide Button If Current User Matches Hardcoded Email In this article I will show 3 ways to show/hide a button in Power Apps so you can decide which one is best for you. But the better way is is to check if the current user belongs to a specific Azure AD group or is found in a SharePoint list. The quickest way is to comparing the current user’s email to a hardcoded value to see if it matches. I hope this helps to solve your question.Need to show or hide a button in Power Apps based on the current user? There are several ways to do it. If the option selected from List 1 is Hide, the second tab will be hidden as shown in the image below:. If the option selected from the List 1 field is either None or Show, both the tabs will be visible as shown in the first two print screens below:. Else, if any other option is selected, the second tab is made visible once again.īelow is a print screen of the Behaviour configuration for your reference:-Īlso, I am including a few test screens for your reference:. What this code does is that when the Hide option is selected from the list, the second tab, i.e. Hence, you will need to make the required modifications. Please note, this sample code is not 100% exact to your environment. FieldBehaviours behavioursĭef list1Value = list1.value. Once you have done so, you will need to include some conditions in the Server-Side Behaviour.īelow is a working sample Server-Side Behaviour code for your reference:- import .user.FieldBehaviours You will need to configure a Server-Side Behaviour for the Single Select List.

For your requirement, you can use ScriptRunner's Behaviour.
