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 / Gallery item to show d...
Power Apps
Unanswered

Gallery item to show depending on user or admin

(0) ShareShare
ReportReport
Posted on by

Hi,  I have a gallery with below codes

Onselect property

Switch(
 ThisItem.Title,
 "User",
 Navigate('User Page'),
 "Admin",
 If(
 isAdmin,
 Navigate('Admin Page'),
 Notify("Not Admin, please use the User access")
 );
 UpdateContext({SelectedTab: "Tab1"});
)

Item property

[
 {
 Title: "User",
 Image: checklist
 
 },
 {
 Title: "Admin",
 Image: people
 }
]

It works well but I am wondering if there is a way to show gallery item depending on user or admin login? Basically I want user to see user only while admin can see both user and admin. 

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @MrKoh 

    You can try to use this code in your Gallery- items property:

    If(
    isAdmin , 
    [
     {
     Title: "User",
     Image: checklist
     
     },
     {
     Title: "Admin",
     Image: people
     }
    ],
    [
     {
     Title: "User",
     Image: checklist
     
     }
    ])

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

  • MrKoh Profile Picture
    on at

    Hi, when i add your add, the admin item will disappear regardless if I am admin or not.

     

    I missed out this code where on start property for app. Not sure if it will help

    Set(isAdmin,Not(IsBlank(LookUp('[Test] Champion List', Mail = varUserEmail)))); 

     

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi ,  @MrKoh 

    You need to check if the account is admin , the  "isAdmin" is return true in your side?

    In this logic , if isAdmin=true, it will return :

    [
     {
     Title: "User",
     Image: checklist
     
     },
     {
     Title: "Admin",
     Image: people
     }
    ]

     

    Best Regards,

    Yueyun Zhang

  • MrKoh Profile Picture
    on at

    Yes. I have tested on the original code where if I am not admin (champion list), when i click on the admin item it will prompt below

    Not Admin, please use the User access

     Not the problem is even though I am admin, the admin item will disappear based on below

    If(
    isAdmin 

     

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @MrKoh 

    Thanks for your response! Can you put your "isAdmin" in a Label / Text to check if it return True when you login in as an admin account in your side?

    Best Regards,

    Yueyun Zhang

  • MrKoh Profile Picture
    on at

    Hi, the label return true. Also i noticed when i input your code, i won't be able to select the item to navigate to either user or admin page. Not sure if its is clashing with the onselect property 

     

    If(
    isAdmin , 
    [
     {
     Title: "User",
     Image: checklist
     
     },
     {
     Title: "Admin",
     Image: people
     }
    ],
    [
     {
     Title: "User",
     Image: checklist
     
     }
    ])

     

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi,  @MrKoh 

    Can you show your screenshot ,where you put this code ?

     

    I mean you do not modify your OnSelect code:

    Switch(
     ThisItem.Title,
     "User",
     Navigate('User Page'),
     "Admin",
     If(
     isAdmin,
     Navigate('Admin Page'),
     Notify("Not Admin, please use the User access")
     );
     UpdateContext({SelectedTab: "Tab1"});
    )

     

    And the Gallery- items :

    If(
    isAdmin , 
    [
     {
     Title: "User",
     Image: checklist
     
     },
     {
     Title: "Admin",
     Image: people
     }
    ],
    [
     {
     Title: "User",
     Image: checklist
     
     }
    ])

     

     

    Best Regards,

    Yueyun Zhang

  • MrKoh Profile Picture
    on at

    Hi, I input the code as it is as shown at above on gallery onselect and item property. 

  • MrKoh Profile Picture
    on at

    Beyond the show both item if visible or just user item if user. When I input your gallery item code, during preview when I click on the item, nothing happen. But when I revert back to below then it works again

    [
     {
     Title: "User",
     Image: checklist
     
     },
     {
     Title: "Admin",
     Image: people
     }
    ]
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @MrKoh 

    As in my understand , Gallery only has the items property. And if the isAdmin= true , the table in the items has two items:

    vyueyunmsft_0-1711604454143.png

    If the isAdmin= false, it will show one item:

    vyueyunmsft_1-1711604477322.png

     

    Dose i misunderstand your need?

     

    Best Regards,

    Yueyun Zhang

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard