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

Row level security in Powerapps based on group

Hi,

 

I have a Powerapp in which users enter daily rates based on the group. 

 

The main thing here is each individual enters the rate representing a group. For example, i have 5 groups in which each group has 10 members. A random member of a group enters data daily. I want users to see only their group data. This Power \app doesn't capture user level detail like who entered the data but it takes data as a group.

 

Please let me know if there is any way to solve this challenge.

 

Thanks,

Nisar

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Nisar ,

I am not sure why you are using StartsWith and EndWith and also if you have a date in Calandar Date (in which case there will be an issue with the below.

Filter(
   'Plant Ops_Nisar',
   (
      searchbox_MS_4.Text in Group.Value || 
      searchbox_MS_4.Text in Plant.Value  || 
      searchbox_MS_4.Text in 'CostType'.Value || 
      searchbox_MS_4.Text in 'Calendar Date' 
   )&& 
   Group.Value=vUserGroup
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @Nisar ,

You need a reference list with the user's email address and the group they belong to.

Then at App OnStart do this

Set(
   vUserMail,
   User().Email
);
Set(
   vUserGroup,
   Lookup(
      YourRefListName,
      UserEmailField=vUserMail,
      Group
   )
)

Then your Gallery Items would be something like

Filter(
   YourListName,
   Group=vUserGroup
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Nisar
Frequent Visitor

Hi @WarrenBelz 

 

Thanks for your reply. 

 

The datasource which i have is sharepoint list where in i don't have user's email address in it. Do you mean i need to create another sharepoint list with user's email address and the group they belong to. But after i create it, will the powerapp accept 2 sharepoint list as datasource and will it not affect the formulas? 

 

Thanks,

Nisar

Hi @Nisar ,

I have an app with over 30 SharePoint lists as data sources, so two will work well.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

Nisar
Frequent Visitor

@WarrenBelz  Thanks for the clarification.

 

I am new to this powerapps, i find this kind of confusing.

 

I have created another sharepoint list with email address & group. Just wanted know how do we create relationship between 2 lists. 

i mean i have date, group, sub group, productivity, adjustment in one sharepoint list and email address & group in another sharepoint list. Before to apply formula is there any step i need to follow or can you please provide me the formula with the columns which i specified.

 

Appreciate your help.

 

Thanks,

Nisar

Hi @Nisar ,

I must have missed your post.

You can reference any connected list in LookUps. I see you have the Group as the common value. What are you wanting to reference and how?

Hi @Nisar ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Nisar
Frequent Visitor

Hi @WarrenBelz 

 

Thank you so much for helping me by providing the code. I Still can't get RLS up & running after using the code. Also i have been using filter function in the form to filter data based on search box (using filter instead of search because "search" can't be used in choice data type from SharePoint.

 

Please find the code below and kindly let me know if i am making any mistake.

 

On start: 

Set(
vUserMail,
User().Email
);
Set(
vUserGroup,
LookUp(
'Plant Ops_RLS test',
'E-mail address'=vUserMail,
Group
)
)

 

I am using datatable in the form so implementing the same there 

Items:

Filter('Plant Ops_Nisar',StartsWith(Group.Value,searchbox_MS_4.Text) || StartsWith(Plant.Value,searchbox_MS_4.Text) || EndsWith(Plant.Value,searchbox_MS_4.Text) || StartsWith('Cost Type'.Value,searchbox_MS_4.Text) || EndsWith('Cost Type'.Value,searchbox_MS_4.Text)|| searchbox_MS_4.Text in 'Calendar Date' && Group.Value=vUserGroup )

 

Thanks,

Nisar

Hi @Nisar ,

I am not sure why you are using StartsWith and EndWith and also if you have a date in Calandar Date (in which case there will be an issue with the below.

Filter(
   'Plant Ops_Nisar',
   (
      searchbox_MS_4.Text in Group.Value || 
      searchbox_MS_4.Text in Plant.Value  || 
      searchbox_MS_4.Text in 'CostType'.Value || 
      searchbox_MS_4.Text in 'Calendar Date' 
   )&& 
   Group.Value=vUserGroup
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Nisar
Frequent Visitor

@WarrenBelz  You're the best. You knocked me off my feet!.

 

Thank you so much for helping me with the code also to correct the existing code. 

 

The code works the way we wanted. I appreciate it.

 

Thanks,

Nisar

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,557)