cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nathan5
Frequent Visitor

Making a button visible for certain users in a sharepoint list

Hi guys,

 

so first of let me explain some things about the app that I Have currently someone else was working on this in the past but isn't available anymore to pick it up further.

So the app is a place with all our services where users can subscribe and get an email if there is an outage.

Now this is done by the admins thats including me So I can see the admin button that we have added but now we want to make that for Product owners so  they can put there own Service on available again if needed or a planned  maintenance.

So they will need to see the admin button for there service

 

Now I want to do that with a new sharepoint list where I have the following.

Name: sees everyone is the AD

Service: is a lookup from another list on the site

 

So I get to the point I create a Collection and A Var with the following code

ClearCollect(ColServiceAdmin, ServiceAdmin);
Set(VarServiceAdmin, ColServiceAdmin);
Refresh(ServiceAdmin);

 

 

Not sure if this is enough to do it but once I go to the Icon that needs to be visible I do VarAdmin is this is for me and someone else.

VarAdmin Or VarServiceAdmin

 

But with VarServiceAdmin after the Or I'm getting an error message that state invalid argument type. expecting one of the following: Boolean, number, text, OptionSetValue

 

Can anyone help me out with this?

9 REPLIES 9
RusselThomas
Community Champion
Community Champion

Hi @Nathan5 ,

Presumably, you need to check the current users email against an email in your collection to see if they qualify to view the icon.  If we look at your statements;

ClearCollect(ColServiceAdmin, ServiceAdmin);  <-- collects data from ServiceAdmin source 
Set(VarServiceAdmin, ColServiceAdmin); <-- sets your variable VarServiceAdmin to be the same as your collection
Refresh(ServiceAdmin); <-- refreshes your ServiceAdmin source

If we check you Visible: property expression;

VarAdmin Or VarServiceAdmin

 The expression needs to evaluate to either true or false.  The way you've expressed it, either VarAdmin OR VarServiceAdmin need to be true for the icon to be visible.  In this case, VarServiceAdmin is a table - not a true or false value.

Again, assuming this is working for admins, then if you look through the app, you should find where VarAdmin is being set - and in theory, it should be set to true or false based on whether the user matched up to some list somewhere.  You would need to apply the same logic to VarServiceAdmin, just using the ServiceAdmin source.

Unfortunately, if you're using person/group columns in SharePoint to store user objects, you can't just do a straight filter or in statement to see if the user exists in there. 

I would always recommend adding a plain text field and storing the users Email in there as a string. If you had a such a column, you might be able to set something like this;  

Set(VarServiceAdmin, User().Email in colServiceAdmins.AdminEmailColumn)

Where the variable VarServiceAdmin will be true if the users email is in the "AdminEmailColumn" column of the colServiceAdmins collection - whatever that column name happens to be.

Then your Visible property should work, as it will resolve to a true or false value.

Hope this helps,

RT

@RusselThomas hi Russel thanks for the quick response on my topic


@RusselThomas wrote:

I would always recommend adding a plain text field and storing the users Email in there as a string. If you had a such a column, you might be able to set something like this;  

 


Do you mean to add a plain text field in the sharepoint list where the mail is being added?

 

This is the code that is being used to set the VarAdmin it refers back to office365 groups

Set(VarAdmin, If(User().Email in Office365Groups.ListGroupMembers("xxxxxxxxxxxxxx").value.userPrincipalName,true,false));

Hi @Nathan5 ,

Yes - so for admins they're checking group membership using the O365Groups connector - for this to work, admins would need to be added to that group/team.  For your serviceAdmins however, it looks like you're keeping a list instead?

If so, then you can keep  your person/group column Name: field, but add another column and call it something like AdminEmailColumn and capture the service admin users emails in there. 

 

To make it easier, you can create a 'serviceAdmin' screen on your app (if there isn't one already) to add/remove users from this list, and make that screen accessible to only Admins. 

You can add an Edit form, set it to your serviceAdmin list as the source and set it's default mode to New.

The form will automatically set up the fields, including a ComboBox for the Name field, a dropdown or text input for your Service field depending on what you've configured it in SPO as, and a text input for the AdminEmailColumn field. 

The combobox will let you search and add users from AD to the list.

Take note of your ComboBox name, it's likely to be something like DataCardValue3 or something.

You can then set the Text: property of the AdminEmailColumn text input to something like

 

DataCardValue3.Selected.Email

 

When you select users in the combo, the text input should then update itself with their email address, and this will get saved back to your list.  You can then use it to check the current users email against in the logic discussed above.

I also suggest you add a label to the serviceAdmin screen just to test - set it's value to User().Email - this will show how PowerApps detects your email address.  Then find your name from the combobox and ensure your test label and the text input values match. 

(Sometimes the email value for a user could be coming from one of two places - the Email field or the userPrincipleName field - both are email addresses and for the most part are usually identical - but in some organisations they are not identical as one is actually usable for an alias to your principle name.  If they are different, we'll have to add a step to get the right one, but we can cross that bridge if we need to).

Kind regards,

RT

@RusselThomas  for us the UserPrincipalName and email are not identical so we would have to cross the bridge my brain is still processing everything that you have written down as I'm completely new to powerapps

No worries Nathan, let's get there first - we all started somewhere, you just have a handicap in that you're already deep in an existing app trying to make changes to it.

The User().Email is usually the userPrinciple, so if we store that we should be fine.  If it doesn't match your test label, we can do a lookup to Office365Users and get the right one easy enough.

For now, don't worry about the serviceAdmin screen and edit form - just add the single line of text AdminEmailColumn column to your ServiceAdmin list and manually capture a your own account and email into it - we can then test the visibility of the icon. 

Once you've got the visibility on the icon working, you can worry about making it a little more user friendly with a screen that auto-captures everything for you.

Kind regards,

RT

 

So I added a single line of text to my sharepoint list with the name AdminEmailColumn and typed in my UserPrincipalName.

When I'm adding the following code like you mentioned before, AdminEmailColumn is red underlined with the following message Name isn't valid This identifier isn't recognized

Set(VarServiceAdmin, User().Email in ColServiceAdmin.AdminEmailColumn);

  

RusselThomas
Community Champion
Community Champion

Hi @Nathan5 ,

So PowerApps caches your data source information on first connect.  Thereafter it assumes that while the data inside the source changes, the data source columns and configuration doesn't change - which it shouldn't.  When you're building though, you're often adding columns - so each time you do this you have to 'tell' PowerApps to fetch the data source info again - which includes columns, data types, and column configurations.

If you select Data Sources (database icon on the left) and look next to your ServiceAdmin list source, you should see a three dot menu ...

If you click this, you can select "Refresh" - this will tell PowerApps to go fetch the data source info again.

This should fix the error - let me know how it goes.

I should emphasise, you only need to do this if you mess with your data structure (like adding/removing columns or changing data types) - you don't need to do this when you're just adding/removing data.  For your session, PowerApps understands when you manipulate data and will auto-refresh the source data each time you do.  If you want to see when others have added/removed data you can use a function called Refresh() - but for refreshing data source info, using the three dot ... menu and clicking Refresh is the only way.  Either that or restart your whole edit session 🙂

Kind regards,

RT

So The error is gone and the Var is working but now it shows the settings icon for all the services but it only needs to show the user the icon for the one that is added in the SPO list

Hi @Nathan5 ,

Glad to hear it 🙂

Can you share a few screenshots that show the gallery, the icons and perhaps the visible property of the icons you're trying to show/hide?

Also, I assume you're an admin as well, so you will probably see all the admin-related icons, as well as the serviceAdmin related icons?

Kind regards,

RT

Helpful resources

Announcements

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

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