I am trying to figure out how to implement row level security in my Power Apps Canvas App... The app will have a basic form where users will be able to create a new record. For example, a user will enter the Reporting Date (date picker), Fac Name (drop down) and Admits (free text). The Fac ID, Area and Region fields will auto-populate (Lookup formula referencing a SharePoint facility list) based on the data entered in Fac Name.
Form (Insert Record):
Reporting Date | 8/29/2023 |
Fac Name | Chicago |
Admits | 5 |
Fac ID | 150 |
Area | Smith |
Region | Wilson |
From lowest level management to highest, each facility has a Program Director (info not stored in SharePoint list below), Area Director and Regional Director. Typically a Program Director will only be responsible for one facility, but in same cases may oversee two or three. The Area Director will cover a small group of sites and the Regional Director will cover a larger group of sites.
SharePoint Facility List:
Facility | Area | Region |
150 | Smith | Wilson |
151 | Smith | Wilson |
152 | Smith | Wilson |
153 | Jones | Wilson |
154 | Jones | Wilson |
155 | Jones | Wilson |
156 | Brown | Miller |
157 | Brown | Miller |
158 | Brown | Miller |
159 | Davis | Miller |
160 | Davis | Miller |
161 | Davis | Miller |
Beyond creating a new record, I want users to be able to only read/edit records that were created for a facility where they have responsibilities. For example, the Program Director garcia@example.com should only have access to facilities 151 and 152. The Area Director smith@example.com should only have access to facilities 150, 151 and 152. The Regional Director wilson@example.com should only have access to facilities 150, 151, 152, 153, 154, and 155. My initial thought is to create a SharePoint user list, like the example below.
From there I am a little lost... I assume I will need to somehow filter a gallery/data table based on the current users 'User().Email' as it relates to the SharePoint user list? I'm a novice a SharePoint and don't really know where to start here...
SharePoint User List
Other thoughts. Would there be a simpler way to store the Area and Region emails in the SharePoint user list since Area and Region are fields that are recorded on the form? Maybe some sort of 'triple filter' that filters first by matching on Fac ID, then on Area, then on Region?
This is all just filtering on the front end within Power Apps... Which I am guessing is not super secure as anyone with access could get to all the data in SharePoint. Is there a better way to do this? Anything I saw on Google appeared to get pretty complicated within Power Automate and didn't really match my use case.
Any help here would be much appreciated!
Solved! Go to Solution.
I ended up going a slightly different direction. Instead of trying to filter a gallery/data table by the user's permission's all at once - I decided to add all the allowed facilities in a collection and add to a dropdown. The gallery/data table can then be filtered by the facility dropdown. Not exactly how I wanted it, but I think this approach will be a little cleaner than Reza's hack in the YouTube video.
So I have a 3 column list setup in SP (called sp_users) with column headers email, type and permission.
I created 5 collections based on the 5 types of users groups there are possible (Admin, Facility, Area, Region & LOB), filtering by current user email.
The permission column will either have the Facility ID in it or the Area, Region or LOB name - or it will say Admin if the user should have global access.
I check the first collection (UserCollectionAdmin) if the user is an Admin (FacilityCollection is an existing collection that list all of our facilities). If so they get all active HRS facilities, otherwise the remaining 4 collections are checked and combined. So it is possible for someone to have a combination of Facility, Area, Region & LOB permissions in the PermissionCollection.
Finally I add a concatenated column and end up with my final ListCollection that my dropdown uses.
ClearCollect(UserCollectionAdmin, Filter(sp_users, type = "Admin", email = Lower(User().Email)));
ClearCollect(UserCollectionFacility, Filter(sp_users, type = "Facility", email = Lower(User().Email)));
ClearCollect(UserCollectionArea, Filter(sp_users, type = "Area", email = Lower(User().Email)));
ClearCollect(UserCollectionRegion, Filter(sp_users, type = "Region", email = Lower(User().Email)));
ClearCollect(UserCollectionLOB, Filter(sp_users, type = "LOB", email = Lower(User().Email)));
If(LookUp(UserCollectionAdmin,"Admin" in permission,true),ClearCollect(PermissionCollection, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS")),
Concurrent(
ClearCollect(col6, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", facility_id in ShowColumns(UserCollectionFacility,"permission"))),
ClearCollect(col7, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", area in ShowColumns(UserCollectionArea,"permission"))),
ClearCollect(col8, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", region in ShowColumns(UserCollectionRegion,"permission"))),
ClearCollect(col9, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", lob in ShowColumns(UserCollectionLOB,"permission")))
);
ClearCollect(PermissionCollection, col6, col7, col8, col9);
Clear(col6);
Clear(col7);
Clear(col8);
Clear(col9);
);
ClearCollect(ListCollection, AddColumns(PermissionCollection,"name_id",location&" - "&facility_id))
Added distinct and sort to have a alphabetized list of facilities with the name and ID of the facility.
Sort(Distinct(ListCollection, name_id),Value,SortOrder.Ascending)
May not be the most elegant solution, but it seems to work for me.
Row Level security in SharePoint really isn't a thing. If you want that you need to look at something like DataVerse but that also comes with extra licensing costs.
This @RezaDorrani video walks through Item Level permissions in SharePoint and may have some ideas for you?
https://www.youtube.com/watch?v=EJyZfYMi4n0
I think the basic takeaway is that Filtering in PowerApps won't stop users from getting full access to your SP data, so you need to think outside the box if you want to setup something like this in an app.
Understood about SharePoint data not being protected.
I’d still be curious about how to go about filtering this within Power Apps so that folks are only looking at the data that matters to them.
Thank you!
Ok then, I think you have picked a tricky app / data problem here. Basically, you need to use a function like 'in' to filter your data by person / email but you will run into delegation issues using 'in'.
One way I see that you may be able to tackle this is by setting up the 'SharePoint User List' with a Choice column for Facility rather than having a record per Facility & User Email, it would look like
User Email FacilityAccess
moore@example.com 150
garcia@example.com 151, 152
robinson@example.com 153
allen@example.com 154
brown@example.com 156, 157, 158
davis@example.com 159, 160, 161
This would also be much easier to manage when adding / removing access to facilities.
Then, in the App OnStart you could add something like this
Set(
vFacilityAccess,
Concat(
First( Filter( UserList, UserEmail = Lower(User().Email))).FacilityAccess,
Value,
", "
)
)
This creates a Text string called vFacilityAccess that holds the facilities the User has access to, which you can reference in a gallery filter to only show facilities that the User has access to. To do that, you can follow @RezaDorrani 's video here where he talks about showing and hiding data - without delegation warnings - and using a Flexible Height gallery to do this.
https://www.youtube.com/watch?v=44j2VRbdWjk
Instead of using the ComboBox demo'd by Reza to help filter, you'd use the text string created above, if that makes sense?
This sounds like a great solution! I much prefer the use of the choice column over the many rows in my original post.
To simply managing these lists further, I think I will want to create 4 SharePoint User Lists.
As Area Director, Region Director and Executive turnover is infrequent. I think this will leave me with just managing the facility based list day-today.
Then I guess would just need a filter in the gallery / data table that looks at those 4 lists using IF OR?
I should have some time to play with this next week. Thanks for your help @EddieE
I ended up going a slightly different direction. Instead of trying to filter a gallery/data table by the user's permission's all at once - I decided to add all the allowed facilities in a collection and add to a dropdown. The gallery/data table can then be filtered by the facility dropdown. Not exactly how I wanted it, but I think this approach will be a little cleaner than Reza's hack in the YouTube video.
So I have a 3 column list setup in SP (called sp_users) with column headers email, type and permission.
I created 5 collections based on the 5 types of users groups there are possible (Admin, Facility, Area, Region & LOB), filtering by current user email.
The permission column will either have the Facility ID in it or the Area, Region or LOB name - or it will say Admin if the user should have global access.
I check the first collection (UserCollectionAdmin) if the user is an Admin (FacilityCollection is an existing collection that list all of our facilities). If so they get all active HRS facilities, otherwise the remaining 4 collections are checked and combined. So it is possible for someone to have a combination of Facility, Area, Region & LOB permissions in the PermissionCollection.
Finally I add a concatenated column and end up with my final ListCollection that my dropdown uses.
ClearCollect(UserCollectionAdmin, Filter(sp_users, type = "Admin", email = Lower(User().Email)));
ClearCollect(UserCollectionFacility, Filter(sp_users, type = "Facility", email = Lower(User().Email)));
ClearCollect(UserCollectionArea, Filter(sp_users, type = "Area", email = Lower(User().Email)));
ClearCollect(UserCollectionRegion, Filter(sp_users, type = "Region", email = Lower(User().Email)));
ClearCollect(UserCollectionLOB, Filter(sp_users, type = "LOB", email = Lower(User().Email)));
If(LookUp(UserCollectionAdmin,"Admin" in permission,true),ClearCollect(PermissionCollection, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS")),
Concurrent(
ClearCollect(col6, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", facility_id in ShowColumns(UserCollectionFacility,"permission"))),
ClearCollect(col7, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", area in ShowColumns(UserCollectionArea,"permission"))),
ClearCollect(col8, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", region in ShowColumns(UserCollectionRegion,"permission"))),
ClearCollect(col9, Filter(FacilityCollection, status = "ACTIVE", lob = "HRS", lob in ShowColumns(UserCollectionLOB,"permission")))
);
ClearCollect(PermissionCollection, col6, col7, col8, col9);
Clear(col6);
Clear(col7);
Clear(col8);
Clear(col9);
);
ClearCollect(ListCollection, AddColumns(PermissionCollection,"name_id",location&" - "&facility_id))
Added distinct and sort to have a alphabetized list of facilities with the name and ID of the facility.
Sort(Distinct(ListCollection, name_id),Value,SortOrder.Ascending)
May not be the most elegant solution, but it seems to work for me.
Sounds like you've got it sorted how you want/need it so well done mate!
I wonder how PowerApps could ever scale without this being available? Is this a 'upsell measure in disguise' by MIcrosoft so that they purchase more DataVerse licenses or what?
Quite honestly, this makes the approach of PowerApps and ShP basically unusable / un-maintainable if you have more than 50 users.
Is there really no other solution to this problem?
Dear Community Members, We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd. During this period, members will not be able to Kudo, Comment, or Reply to any posts. On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities. What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!
We are excited to announce the Summer of Solutions Challenge! This challenge is kicking off on Monday, June 17th and will run for (4) weeks. The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities. Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”) - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024 Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods. You must enter into each weekly Entry Period separately. How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different. Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers. At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing. Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner. A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random. Individuals will be contacted before the announcement with the opportunity to claim or deny the prize. Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners. Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event. ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE** Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08 23 @WarrenBelz 31 @DBO_DV 10 @Amik 19 AmínAA 6 @mmbr1606 12 @rzuber 4 @happyume 7 @Giraldoj 3@ANB 6 (tie) @SpongYe 6 (tie) Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08 10@WarrenBelz 25 @DBO_DV 6@mmbr1606 14 @AmínAA 4 @Amik 12 @royg 3 @ANB 10 @AllanDeCastro 2 @SunilPashikanti 5 @Michaelfp 2 @FLMike 5 @eduardo_izzo 2 Meekou 2 @rzuber 2 @Velegandla 2 @PowerPlatform-P 2 @Micaiah 2 Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27 Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8 SunilPashikanti8
On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners. The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights. Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.
We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for. We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer. Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together. Here's to new beginnings and endless possibilities! If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport. To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages