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 / Disable button if User...
Power Apps
Unanswered

Disable button if User().Email is not equal to Created By.Email

(0) ShareShare
ReportReport
Posted on by 52

Okay here's my situation. I create a page where I have a gallery that displays items from my source table on Sharepoint lists. When a user double clicks an item, I set the OnSelect property as follows:

 

Select(Parent) & Navigate(EditRequestScreen, ScreenTransition.UnCoverRight, {ViewItem: ThisItem})

 

Basically, we just navigate to the EditRequestScreen and we can view the specific item that was selected. 

 

On EditRequestScreen, the items are displayed correctly using Form control. On the screen, I have 2 buttons a Delete button and Edit button. I want to enable users to edit their records in this page. However, users can see other user's records as well which is not an issue. I want to disable the Delete and Edit button if the current user's email is not equal to the Created By email. This is what I have tried on one of the buttons' DisplayMode:

 

If(ViewItem.'Created By'.Email = User().Email, DisplayMode.Edit, DisplayMode.Disabled)

 

Appreciate if anyone could help me with my formula for this purpose 🆘🆘😣 

Categories:
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    TRy using below 2 formulas - 

    If(GalleryName.Selected.'Created by'.Email = User().Email, DisplayMode.Edit, DisplayMode.Disabled)
    OR

    If(Lower(GalleryName.Selected.'Created by'.Email) = Lower(User().Email), DisplayMode.Edit, DisplayMode.Disabled)

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Do your users' Primary SMTP email address and their User Principal Name (login name) match?

     

    I ask this because:

    User().Email gets you the user's User Principal Name

    CreatedBy.Email gets you their Primary SMTP Address

     

    If you want to ensure that both cases are covered, use the following in your Form's DefaultMode property:

    If(Lower(ViewItem.'Created By'.Email) = Lower(Office365Users.UserProfileV2(User().Email).mail) ||
     Lower(ViewItem.'Created By'.Email) = Lower(Office365Users.UserProfileV2(User().Email).userPrincipalName),
     FormMode.Edit,
     FormMode.View
    ) 

     

    image.png

     

    Cheers,

    Sancho

  • laila2021 Profile Picture
    52 on at

    Hi @NandiniBhagya20 your solution works!!!!!

     

    It was not working cause 'Display Name'.Email gave me email address with capital letters at the beginning and User().Email gave me all in lower case (or the other way around). So the formula that works is this one:

     

    If(Lower(ViewItem.'Created By'.Email) = Lower(User().Email), DisplayMode.Edit, DisplayMode.Disabled)

     

    Thank you! 

  • laila2021 Profile Picture
    52 on at

    Thank you @iAm_ManCat! Today I learn the differences!

     

    Unfortunately, my teams are in different tenants at the moment so I am avoiding the use of Office365Users like a plague but your take is interesting and I am adding the OR formula to cover all bases. Appreciate your insight! 🙏

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

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard