cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Continued Contributor
Continued Contributor

DisplayMode based on user

Greetings, 

 

I have a feedback form and I would like the Status card display as with edit option for managers or as view only if not a manager.  I have added a list from SharePoint with the manager names in a screen that will not be visible to the user.  Can you please advise on the function for the Status DisplayMode?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Re: DisplayMode based on user


@Anonymous wrote:

To check whether the current user is in that list of manager names, you can use the in operator.

Reference: https://docs.microsoft.com/en-us/powerapps/functions/operators#in-and-exactin-operators

 

So, you can do something like this:

If( User().FullName in ManagerNames,
    DisplayMode.Edit,
    DisplayMode.View
)

Although, I don't suggest using DisplayMode.View. Using DisplayMode.Disabled is easier since you can customize formatting easier that way. 


 

For performance reasons you may want to set the User() to a variable to decrease the number of calls to that function. I know there are other posts out there explaining all the reasons why but by doing this it speeds up the app considerably.

 

For example on page Visible on your Home screen run:

Set(CurrentUser, User())

Then anytime you ever need to find the user just simply do a CurrentUser.FullName etc. That way you are only calling the User() function once.

 

Otherwise @Anonymous has the right idea, you can display, hide, disable just about anything based on username using the code he supplied.

View solution in original post

2 REPLIES 2
Highlighted
Anonymous
Not applicable

Re: DisplayMode based on user

To check whether the current user is in that list of manager names, you can use the in operator.

Reference: https://docs.microsoft.com/en-us/powerapps/functions/operators#in-and-exactin-operators

 

So, you can do something like this:

If( User().FullName in ManagerNames,
    DisplayMode.Edit,
    DisplayMode.View
)

Although, I don't suggest using DisplayMode.View. Using DisplayMode.Disabled is easier since you can customize formatting easier that way. 

Highlighted
Memorable Member
Memorable Member

Re: DisplayMode based on user


@Anonymous wrote:

To check whether the current user is in that list of manager names, you can use the in operator.

Reference: https://docs.microsoft.com/en-us/powerapps/functions/operators#in-and-exactin-operators

 

So, you can do something like this:

If( User().FullName in ManagerNames,
    DisplayMode.Edit,
    DisplayMode.View
)

Although, I don't suggest using DisplayMode.View. Using DisplayMode.Disabled is easier since you can customize formatting easier that way. 


 

For performance reasons you may want to set the User() to a variable to decrease the number of calls to that function. I know there are other posts out there explaining all the reasons why but by doing this it speeds up the app considerably.

 

For example on page Visible on your Home screen run:

Set(CurrentUser, User())

Then anytime you ever need to find the user just simply do a CurrentUser.FullName etc. That way you are only calling the User() function once.

 

Otherwise @Anonymous has the right idea, you can display, hide, disable just about anything based on username using the code he supplied.

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,020)