web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert Apply To Each ...
Power Automate
Unanswered

Convert Apply To Each with a single Compose action

(0) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1
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
      }
    ]
  }
}
Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at
    I don't know how to solve your issue through a workflow since that is not how I would handle what you are trying to accomplish. Since people need to manually run the flow so the item is set to read only, instead I would use the in-place records management feature built into SharePoint lists. You need to enable this in the site settings, but once enabled it is easy to use. You can read about it at Declare any list or library item as a record - Microsoft Support. When you declare an item a record, it essentially becomes read only. It also allows you to undeclare it a record later on. 
  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at
    What i am showing is only part of my flow, later on the flow will define some users who have Contribute and Contribute without delete (Custom permission level) .. so the item will not be a read-only for all users.. so that why i am doing this as i am showing..

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 507 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 267 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard