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

Announcements

News and Announcements icon
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 2,015 Season of Giving Solutions 2025
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
    14,821 Super User 2026 Season 1 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
    2,015 Season of Giving Solutions 2025 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 427

#2
Vish WR Profile Picture

Vish WR 316

#3
David_MA Profile Picture

David_MA 260 Super User 2026 Season 1

Last 30 days Overall leaderboard