cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JoeVolk
Helper I
Helper I

Show/Hide Button based on Current User Matching People Picker Field

I have a screen with a gallery and display form on it. The display form has data populated that is stored in a list in SPO. One of the fields is a people picker field that has the display name of a user in it. I want to show/hide a button on the same screen based on if the user in that people picker field matches the current user. I have created a variable that populates the current user and have verified the proper user data is in that variable. I have been trying this formula in the Visible property of the Button:

 

If(varCurrentUser = Submitter_DataCard4.DisplayName,true,false)

 

The button is not visible even thought the current user matches the Submitter Display Name. What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions

@JoeVolk 

Oops, sorry, typo in the formula I gave you - actually an exclusion. 

 

varCurrentUser = First(galUpcomingOutages.Selected.PeoplePickerColumn).DisplayName

And here, put in the name of the PeoplePicker column from your list.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
RandyHayes
Super User
Super User

@JoeVolk 

Assuming you are actually getting the correct value for the Submitter_DataCard4.DisplayName (you can verify by placing your cursor on it in the formula editor) I would check case.

Try : 

   Upper(varCurrentUser) = Upper(Submitter_DataCard4.DisplayName)

 

TIP: You don't need the If statement around it, if the statement evaluates to true, it will be true.

 

But...check that DisplayName value as mentioned above to make sure you have a value there that you expect.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks for the info @RandyHayes . I am not getting the correct value for the Submitter_Datacard4.DisplayName. It is just returning the name of the field as it is in SharePoint: Submitter. How do I get the proper value out of that field? I tried using DatacardValue40.____________, but that isn't working or giving me anything from that field. The value being displayed in that field is currently correct, but I need to somehow get it out to compare. Appreciate the help.

@JoeVolk 

 

So, my assumption then is that you have set up your People Picker column in SharePoint to allow multiple selections.  If so, then there is really a table of people in that column. 

I would take the DisplayForm out of the equation at this point as you really don't need it (this is based on the assumption that you are displaying data in the display form based on a selection from the Gallery).

If that assumption is all good to this point then...

If you know there will only be one name in there (even though you have it set to allow multiple) then you can change your formula to this:

varCurrentUser = First(GalleryName.Selected).DisplayName

(substitute the name of your gallery in the galleryname above)

 

If you WILL have multiple people in that column, then change to the following:

varCurrentUser in GalleryName.Selected.DisplayName

(again, substitute the name of your gallery in the galleryname above)

 

See if this moves you forward.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

My column in SharePoint is not set to allow multiple values. It will always be only one name in that field 

 

I tried the formula below and it won't resolve. Here is what I am getting.

powerapps-variable.png

 

 

@JoeVolk 

Oops, sorry, typo in the formula I gave you - actually an exclusion. 

 

varCurrentUser = First(galUpcomingOutages.Selected.PeoplePickerColumn).DisplayName

And here, put in the name of the PeoplePicker column from your list.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

I was still getting the same error with the updated formula. I removed First() from the formula and it works just fine now. Thanks for the quick help!

@JoeVolk 

Very good! 

But double check your column settings for the people picker.  If you were able to get it to work without the First statement, then it can't possibly be set to allow multiple people selections.

At any rate...glad you jumped that hurdle.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thats interesting. I just confirmed and the column in SharePoint has Allow Multiple Values set to No. I also went in to the app to try and add a second name to the field and it won't let me do that. It just replaces the existing person with the new user I typed in. 

 

I guess it works so I can't complain. Thanks again!

 

@RandyHayes 

@JoeVolk 

That is correct then.  Your column is NOT set to allow multiple people.  So, the formula (without the First) is correct.

 

Well, keep this tidbit in your pocket for the future in case you need to deal with a multiple selection people picker column.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,969)