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 / Hiding fields from user
Power Apps
Answered

Hiding fields from user

(0) ShareShare
ReportReport
Posted on by 1,625

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

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @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 Profile Picture
    1,625 on at

    Hi @mdevaney 

     

    please see attached

    varapprover.PNG
    VarUser.PNG
  • mdevaney Profile Picture
    29,991 Moderator on at

    @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 Profile Picture
    1,625 on at

    HI @mdevaney 

    apologies, attached with error

     

     

    VarUser.Email.PNG
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @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."

  • Lefty Profile Picture
    1,625 on at

    @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?

  • mdevaney Profile Picture
    29,991 Moderator on at
    @Lefty
    Are you saying this function evaluates to true but the field is still disabled?

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

  • Lefty Profile Picture
    1,625 on at

    @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

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 413

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
timl Profile Picture

timl 315 Super User 2026 Season 1

Last 30 days Overall leaderboard