cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Koerts
Level: Powered On

Patch, ForAll, Flow or something else?

Hello,

 

This is my first post in this community, so be gentle please :-). I'm kinda stuck and running out of options here.

Let me sketch the situation:

I have 2 SharePoint lists related as 1 to many through a search column.

 

List1

main columns:

name (text); assigned to (person)

 

List2 containing logs:

Main column:

Name (search in list1)

 

List1 has a 2010 workflow that changes permissions based on "assigned to" column

I would like to find a solution that changes the permissions of all logs in list2 according to the "assigned to" field in list1.

 

I have a PowerApp on top of that where people can submit their logs.

 

The latest i have tried is trying to patch (with ForAll and patch) all logs in list2 with the "assigned to" value from list1 as soon as you change the value in list1. Which will initiate a similar workflow for list2.

 

Does anyone have any suggestions on how to achieve this.

8 REPLIES 8
R3dKap
Level 10

Re: Patch, ForAll, Flow or something else?

Hi @Koerts,

From my point of view, there are 2 solutions to your problem:

  1. From PowerApps your trigger a flow that takes the Name and the AssignTo values from List1 as an input; the flow then changes the permissions of all items in List2 for the given Name value
  2. You create a flow that is triggered when an item is created or updated on List2; the flow first searches for the corresponding Name item in List1 to figure out the value of AssignTo and then changes the permissions of the current item accordingly

To change the permissions of a list item through a flow, you can do it using HTTP request like this:

Image 5.png

Some explanations here:

  • ID is the item ID for which you wish to change the permissions
  • iGroupeID should be replace with the AssignTo user's ID
  • sNivPermID is the permission level ID (you can find their values here)

Hope this helps,

Emmanuel

 

PS: by the way, you cannot change permissions using Power Apps directly.

Community Support Team
Community Support Team

Re: Patch, ForAll, Flow or something else?

Hi @Koerts ,

Could you please share a bit more about your scenario?

Do you want to change the List Item permission in your List 2 based on the 'assigned to' column in your List 1?

Do you add a similar Person type column in your List 2?

 

If you have added similar Person type column in your List 2, I think the ForAll function and Patch function PowerApps could achieve your needs.

You could consider sync the 'assigned to' field value from your List 1 to the Person type column in your List 2, then based on the Person type column in your List 2, re-configure your Workflow to change the permission.

Please consider generate an app, then add your SP List data sources in it. Add a "Submit" button, please set the OnSelect property to following:

ForAll(
       List1,
       Patch(
             List2,
             LookUp(List2, Name = List1[@name]),
             {
                PersonColumn: List1[@'assigned to']
             }
       )
)

or

ForAll(
       List1,
       Patch(
             List2,
             LookUp(List2, Name = List1[@name]),
             {
                PersonColumn: {
                                Claims: "i:0#.f|membership|" & Lower(List1[@'assigned to'].Email),
                                DisplayName: List1[@'assigned to'].DisplayName,
                                Email: List1[@'assigned to'].Email,
                                Department:"",
                                JobTitle:"", 
                                Picture: ""
                              }
             }
       )
)

Note: The PersonColumn represents the Person type column in your List 2. On your side, you should re-configure your workflow in your List 2 based on the PersonColumn to change the List Item Permission.

 

In addition, I also agree with @R3dKap 'thought almost. You could consider set up a MS Flow (Power Automate) to change the permission in your List 2 based on the 'assigned to' value from your List 1 (using "Send an HTTP request to SharePoint" action of SharePoint connector).

On your side, you could consider add a "When an item is created or modified" trigger in your flow to act as the Trigger (applied to your List 1), and then add a "Send an HTTP request to SharePoint" action to change the permission in your List 2 based on the 'assigned to' field value returned from above Trigger.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Koerts
Level: Powered On

Re: Patch, ForAll, Flow or something else?

Thank you @R3dKap ,

 


@R3dKap wrote:

Hi @Koerts,

From my point of view, there are 2 solutions to your problem:

  1. From PowerApps your trigger a flow that takes the Name and the AssignTo values from List1 as an input; the flow then changes the permissions of all items in List2 for the given Name value

I've tried to make a flow with a HTTP-request before, but I could not get it to work. Unfortunately I have to admit that there is a limit to what I can figure out myself (without any coding knowledge)

 


@R3dKap wrote:

Hi @Koerts,

From my point of view, there are 2 solutions to your problem:

  1. From PowerApps your trigger a flow that takes the Name and the AssignTo values from List1 as an input; the flow then changes the permissions of all items in List2 for the given Name value
  2. You create a flow that is triggered when an item is created or updated on List2; the flow first searches for the corresponding Name item in List1 to figure out the value of AssignTo and then changes the permissions of the current item accordingly

The thing with point 2 is that the items in list2 are already created and they have to be changed when the related item in list1 changes. In that case will the workflow not be triggered because it is not created or updated.

Koerts
Level: Powered On

Re: Patch, ForAll, Flow or something else?

Hello @v-xida-msft ,

 

Thank you for your explanation.

 


@v-xida-msft wrote:

Hi @Koerts ,

Could you please share a bit more about your scenario?

Do you want to change the List Item permission in your List 2 based on the 'assigned to' column in your List 1?

Do you add a similar Person type column in your List 2?


Yes I would like to  change the list item permissions in List2 based on the 'assigned to' column in List1.

Yes I did add a similar person type column in List2, but I did understand that person columns in PowerApps can be a bit tricky, so I tried it with a text column as well.

 

ForAll(
       Leerlingen;
       Patch(
             Logboek;
             LookUp(Logboek; [Leerling] = Leerlingen.Achternaam);
             {
                'Mentor (persoon)': Leerlingen[@'Toegewezen aan']
             }
       )
)

This is what I have tried. But it gives me an error on the =. Saying it is an invalid argumenttype.

 

What am I doing wrong?

Dual Super User
Dual Super User

Re: Patch, ForAll, Flow or something else?

Hey @Koerts 

 

Can you share some details about the schema of these two lists along with the datatype?

Also, can you try to update the expression as:

ForAll(
Leerlingen;
Patch(
Logboek;
LookUp(Logboek; Leerling = Achternaam);
{
'Mentor (persoon)': Toegewezen aan
}
)
)

This is an invalid error because Leerlingen.Achternaam returns a one column table of all the values in Achternaam column in your Leerlingen list, which is incompatible with the Lerring column of Logboek List.

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

R3dKap
Level 10

Re: Patch, ForAll, Flow or something else?

Hi @Koerts,

You are right: you would need to trigger your flow on creation or update of items in List1.

Community Support Team
Community Support Team

Re: Patch, ForAll, Flow or something else?

Hi @Koerts ,

Based on the formula you provided, I think there is something wrong with it. Please consider modify your formula as below:

ForAll(
       Leerlingen;
       Patch(
             Logboek;
             LookUp(Logboek; Leerling = Leerlingen[@Achternaam]);  // Modify formula here 
             {
                'Mentor (persoon)':  Leerlingen[@'Toegewezen aan']
             }
       )
)

Note: The Leerlingen.Achternaam formula would return a table value, which could not be compared with a Text value using '=' operator directly.

or

ForAll(
       Leerlingen;
       Patch(
             Logboek;
             LookUp(Logboek; Leerling = Achternaam);  // Modify formula here 
             {
                'Mentor (persoon)':  Leerlingen[@'Toegewezen aan']
             }
       )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Koerts
Level: Powered On

Re: Patch, ForAll, Flow or something else?

@v-xida-msft 

 


@v-xida-msft wrote:

Hi @Koerts ,

Based on the formula you provided, I think there is something wrong with it. Please consider modify your formula as below:

 

ForAll(
       Leerlingen;
       Patch(
             Logboek;
             LookUp(Logboek; Leerling = Leerlingen[@Achternaam]);  // Modify formula here 
             {
                'Mentor (persoon)':  Leerlingen[@'Toegewezen aan']
             }
       )
)

 

Note: The Leerlingen.Achternaam formula would return a table value, which could not be compared with a Text value using '=' operator directly.

or

 

ForAll(
       Leerlingen;
       Patch(
             Logboek;
             LookUp(Logboek; Leerling = Achternaam);  // Modify formula here 
             {
                'Mentor (persoon)':  Leerlingen[@'Toegewezen aan']
             }
       )
)

 

 

Best regards,


I tried both formulas without succes. It still gives me a squigly on the = with error 'Invalid argumenttype'.

Maybe we're missing something. The setup of the SharePoint lists is as followed.

 

List1 (containing solely participants)

Unique column will be 'Surname' (text)

Permission column will be 'assigned to' (person)

 

List2 (containing Log entries, multiple logs for 1 participant)

Search column named 'Participant' (search), searches in List1 column 'Surname' (text)

Permission column named 'Mentor' (person)

 

The Person columns 'Assigned to' and 'Mentor' I call them permission columns because the workflows will use them to set permissions.

 

Hope this makes sense...

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,192)