cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Lefty
Level: Powered On

Hiding fields from user

Hi

 

I'd like to 'hide' some  fields on my canvas app to certain users, I think I'm nearly there but struggling with the syntax.

I have on my App OnStart:

Set(VarUser, User().Email);
Set(Approver, LookUp(ListName, Email = VarUser))

 

On my field DisplayMode i have put the following:

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

But i'm getting a red line under = cant see how I get this to work, unless someone has a better suggestion.

The ListName I am 'lookup' has 1 email address (for now) with a coloumn titled Email and the email address is free text, (unless i can set this to person field and it would still work)?

I would like to store all the approvers in this SPO list and the columns i would set to be in edit mode only if the users were in that list.

I tried working with collections, but my items would get deleted and i would like to use this same approver list for many different apps, it makes sense to use a SPO list i can use multiple times.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Hiding fields from user

@Lefty 

I missed something in your original problem statement.

 

Your code currently looks like this:

Set(VarUser, User().Email);
Set(Approver, LookUp(ListName, Email = VarUser))

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

The reason for the error message is you are comparing VarUser (a text string) to Approver (a person object).

 

Change your code to this:

Set(VarUser, User().Email);
Set(Approver, LookUp(ListName, Email = VarUser, Email))

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

8 REPLIES 8
Super User
Super User

Re: Hiding fields from user

@Lefty 

Replace this code

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

With this code

If(VarUser.Email = Approver.Email, DisplayMode.Edit, DisplayMode.View)

 

If that does not work please provide a screenshot of the error message.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Lefty
Level: Powered On

Re: Hiding fields from user

Hi @mdevaney 

 

please see attached

Super User
Super User

Re: Hiding fields from user

@Lefty 

Can you please try either of these code ideas?  Sorry I had edited my answer while you were typing

If(VarUser.Email = Approver.Email, DisplayMode.Edit, DisplayMode.View)
If(VarUser.Email = Approver.Mail, DisplayMode.Edit, DisplayMode.View)

 

The screenshot you provided does not show the error message, only the red underline. 😞   Can you please supply the error message?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Lefty
Level: Powered On

Re: Hiding fields from user

HI @mdevaney 

apologies, attached with error

 

 

Super User
Super User

Re: Hiding fields from user

@Lefty 

I missed something in your original problem statement.

 

Your code currently looks like this:

Set(VarUser, User().Email);
Set(Approver, LookUp(ListName, Email = VarUser))

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

The reason for the error message is you are comparing VarUser (a text string) to Approver (a person object).

 

Change your code to this:

Set(VarUser, User().Email);
Set(Approver, LookUp(ListName, Email = VarUser, Email))

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Lefty
Level: Powered On

Re: Hiding fields from user

@mdevaney 

Ah so the function works, but the field is also disabled for me, I checked my User.().Email and the format in the SPO list is as its displayed in my text box... refreshed the data source but still the field stays disabled.

Can i use a person field from SPO list as opposed to using a free text column where a user is to type in the email address and using that column as the lookup?

Super User
Super User

Re: Hiding fields from user

@Lefty
Are you saying this function evaluates to true but the field is still disabled?

If(VarUser = Approver, DisplayMode.Edit, DisplayMode.View)

Lefty
Level: Powered On

Re: Hiding fields from user

@mdevaney 

Yes that's correct as my email address is in the SPO list

I've saved, published and gone back into the form and seems to be working

Thank you for all your help

Helpful resources

Announcements
thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,941)