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 / Apply_to_each keeps on...
Power Automate
Unanswered

Apply_to_each keeps on running infinitely for long arrays

(1) ShareShare
ReportReport
Posted on by
i have a very large json. The format is as below:
{

  "EmployeeDetails": {

    "UserInfo": [

      {

        "EmployeeID": 25450,

        "FirstName": "Ram",

        "MiddleName": "Kumar",

        "LastName": "Bharati",

        "Username": "rambh111",

        "Status": "ACT",

        "WFHRecords": [

          {

            "Date": "2022-05-24",

            "Year": "2022",

            "Month": "5",

            "Day": "24",

            "WFH": true,

            "WFHApproved": true,

            "WFHRemarks": "Working from home"

          },

          {

            "Date": "2024-07-02",

            "Year": "2024",

            "Month": "7",

            "Day": "02",

            "WFH": true,

            "WFHApproved": true,

            "WFHRemarks": "Working from home for COVID"

          }

        ]

      },

      {

        "EmployeeID": 25451,

        "FirstName": "Rakshya",

        "MiddleName": "",

        "LastName": "Panta",

        "Username": "rapan062",

        "Status": "ACT",

        "WFHRecords": [

          {

            "Date": "2023-10-20",

            "Year": "2023",

            "Month": "10",

            "Day": "20",

            "WFH": true,

            "WFHApproved": true,

            "WFHRemarks": "Work from home"

          },

          {

            "Date": "2024-07-02",

            "Year": "2024",

            "Month": "7",

            "Day": "02",

            "WFH": true,

            "WFHApproved": true,

            "WFHRemarks": "Working from home"

          }

        ]

      }

    ]

  }

}



There are many users and their WFHRecords is also very large. For above json, the flow is working fine But issue is showing for longer arrays (170  users and more than 500 WFHRecords ).

Apply_to_each_Employee keeps on running for longer json. Also while testing bad gateway is displayed. What is the issue here? Is it because the json is tooo large? cause this same flow works fine for smaller json.
Categories:
  • creativeopinion Profile Picture
    10,508 Moderator on at
    It's always best practice to filter out your items before looping through them. In your case it seems like you only want to loop through items where WFH = true. In that case, you should use a Filter Array action. Currently you are looping through all 170 items and running a check on every item to see if it matches your criteria. By filtering out your items first, you will only loop through those that match your criteria. Let's say you have 10 items that match your criteria. It's more efficient to loop through 10 items instead of 170 and run a condition check. 
     
    To learn more about how to use the Filter Array action, please refer to this YT Tutorial: Are you using the Microsoft Power Automate Filter Array Action wrong?

    In this video tutorial I’ll show you 3 practical ways to use the Filter Array action and how to use it properly.
    1️⃣ Cross-Referencing Data
    2️⃣ Filtering by Key
    3️⃣ Substring Matching

    Did you know that the Condition action has a limit of 10 conditions? Although it might look like the Filter Array action can only accept one condition—this is not true. By using the advanced mode you can enter multiple conditions into a Filter Array action with an expression.

    IN THIS VIDEO:
    ✅ 3 Ways to Use the Filter Array Action
    ✅ How to use the Scope Action to Group Actions
    ✅ How to Check the Number of Items returned from a Filter Array Action
    ✅ How to Cross-Reference Data in Excel with a SharePoint List
    ✅ How the Filter Array Action Works
    ✅ How to Access the Dynamic Content from a Filter Array Action
    ✅ How to Filter Items by a Key
    ✅ How to Filter Items by Matching a Substring
    ✅ How to Use Multiple Conditions in a Filter Array Action
     
     
    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.

    Consider giving me a ❤️ if you liked my response!

    👉 Level up your Power Automate skills by checking out my tutorials on YouTube
    👉 Tips and Tricks on TikTok and Instagram
  • VictorIvanidze Profile Picture
    13,083 on at
    You just have to redesign your flow.  
  • rapan062 Profile Picture
    on at

    I redesigned the flow using filter array and now it is working as i wanted. Thank you all.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 423

#2
11manish Profile Picture

11manish 308 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 177

Last 30 days Overall leaderboard