I have this child flow, which do the following main actions to define a list item as Read-Only:-
1) Receive an ItemID/ListID parameters.
2) Break the Item permission inheritance
3) Loop through the item permissions list
4) Remove the permission and reassign it with Read . I am doing this inside a Batch request, as shown below.
Currently i am doing these actions:-
So currently this has 2 main issues:-
1) Its execution time, as sometimes a list item can have 10-12 permissions, so this means the ApplyToEach will get executed 12 times and 12 Batch request will be sent.
2) On some days where we have a lot of actions been performed on SharePoint, this flow will executed more than 100K requests and i get an email from Microsoft that this flow is execution too many actions.
so i am not sure if i can tune this flow, mainly to join all the Batch requests into a single request? this will allow me to:-
1) Increase the performance of the flow
2) Reduce the number of requests been performed by the flow
now i know that i can define an Array variable, and append it with the Batch request body, then send a single Batch to SharePoint, this will defenitly increase the performance of the flow, but will still make the same number of requests, since i will have an ApplyToEach to build the Array ..so can i use XPath ? or other approachs to allow me to build the single batch request without executing too any actions?
here is the JSON of the permissions list, i am getting from the "get roleassignments" action, and which i am ApplyToEach on them and send separate Batch requests
{
"d": {
"results": [
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(3)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(3)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(3)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(3)/RoleDefinitionBindings"
}
},
"PrincipalId": 3
},
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(4)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(4)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(4)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(4)/RoleDefinitionBindings"
}
},
"PrincipalId": 4
},
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(5)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(5)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(5)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(5)/RoleDefinitionBindings"
}
},
"PrincipalId": 5
},
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(6)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(6)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(6)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(6)/RoleDefinitionBindings"
}
},
"PrincipalId": 6
},
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(14)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(14)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(14)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(14)/RoleDefinitionBindings"
}
},
"PrincipalId": 14
},
{
"__metadata": {
"id": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(15)",
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(15)",
"type": "SP.RoleAssignment"
},
"Member": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(15)/Member"
}
},
"RoleDefinitionBindings": {
"__deferred": {
"uri": "https://***sms.sharepoint.com/sites/***-PPM-Test/_api/Web/Lists(guid'3ea955ac-e208-472c-9591-4ecb8d05c982')/Items(2021)/RoleAssignments/GetByPrincipalId(15)/RoleDefinitionBindings"
}
},
"PrincipalId": 15
}
]
}
}