TheWhile Looptask lets you make repeated calls to a sub-integration from
your current (main) integration until a specified condition is met.
TheAPI Trigger IDand theIntegration nameidentifies the sub-integration you
want to run.
The task also lets you collect the response from each sub-integration run and store the value in your
current integration for use in downstream tasks. You can use any of the following approach to collect the responses:
Collate the response of each run in an array variable, where each element of the array has the
response from one particular run. To collate the responses, configure
theCollect values from sub-integration output(s)property.
Aggregate the responses of all the runs in a single variable. To aggregate the responses, configure
theOverride values from sub-integration output(s)property.
Before you begin
Ensure that you haveattached a user-managed service accountto your integration. If your integration does not have user-managed service account configured, then by default thedefault service account(service-PROJECT_NUMBER@gcp-sa-integrations.iam.gserviceaccount.com) is used for authentication.
Ensure that your service account has theApplication Integration InvokerIAM role. For information about granting roles to a service account, seeManage access to service accounts.
Configuration properties
The following table describes the configuration properties of theWhile Looptask.
Property
Data type
Description
API Trigger ID
String
Trigger ID of the sub-integration to run.
This value is available in theTrigger IDfield of theAPI Triggerin the sub-integration.
Integration name
String
Name of the sub-integration to run.
While loop condition
N/A
Condition to terminate the loop. The sub-integration runs till the condition is met. For example,$loopMetadata.current_iteration_count$< 10.
Map to sub-integration input(s)
N/A
Values to pass from the current integration to the sub-integration.
The values of this property are in the form of key-value pairs, where the key is a variable
in the current integration, and the value is the corresponding input variable in the
sub-integration. For example, suppose your main integration has theproductIDvariable, which you want to map to thesubIntProductIDsub-integration variable; you would
selectproductIDfrom theIntegration variable to map fromdrop-down and entersubIntProductIDin theSub-Integration input
to map tofield.
Collect values from sub-integration output(s)
N/A
Collate the results of the sub-integration runs.
Every time the sub-integration runs,
you can store the output of the sub-integration in an array variable of the current integration. Enter the
sub-integration's output variable in theSub-Integration output to collect fromfield and select the array variable in current integration from theIntegration variable to collect intodrop-down. Each element of the array has the response from a
particular sub-integration run. For example, if the array variable isresultsArray,resultsArray[0]has the response from the first run andresultsArray[1]has
the response from the second run.
Override values from sub-integration output(s)
N/A
Read the output variable of a sub-integration run and store it in a variable of
the current integration.
Select the sub-integration's output variable from theSub-integration output to map fromdrop-down, and select the corresponding variable in the current integration from theIntegration variable to overridedrop-down. You can send the overridden variable in the current integration
to the next sub-integration run by mapping the variable in theMap to additional sub-integration
input(s)property. As a result, you can cumulatively aggregate the responses from the
sub-integration runs.
Loop metadata
JSON array
The output variable that has the execution details of the sub-integration runs like the
sub-integration execution ID, errors messages, and variable values passed during execution. Loop metadata contains variables including the following output variables:current_iteration_count,sub_integration_execution_ids,failure_location,current_element,iteration_element, andfailure_message.
Best practices
For information about the usage limits that apply to theWhile Looptask, seeUsage limits.
Error handling strategy
An error handling strategy for a task specifies the action to take if the task fails due to atemporary error. For information about how to use an error handling strategy, and to know about the different types of error handling strategies, seeError handling strategies.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe While Loop task enables repeated execution of a sub-integration until a specified condition is met, identified by the API Trigger ID and Integration name.\u003c/p\u003e\n"],["\u003cp\u003eResponses from each sub-integration run can be collected and stored, either by collating each run's response into an array or by aggregating all responses into a single variable.\u003c/p\u003e\n"],["\u003cp\u003eThe While Loop task has a maximum limit of 8000 iterations, and the cumulative data collected from sub-integration runs cannot exceed 50 MB.\u003c/p\u003e\n"],["\u003cp\u003eA user-managed service account with the Application Integration Invoker role is required for the integration to run, or it will use the default service account.\u003c/p\u003e\n"],["\u003cp\u003eThe task configuration allows mapping variables between the current integration and the sub-integration, managing loop termination conditions, and collecting or overriding sub-integration outputs.\u003c/p\u003e\n"]]],[],null,["# While Loop task\n\nSee the [supported connectors](/integration-connectors/docs/connector-reference-overview) for Application Integration.\n\nWhile Loop task\n===============\n\nThe **While Loop** task lets you make repeated calls to a sub-integration from\nyour current (main) integration until a specified condition is met.\n\nThe **API Trigger ID** and the **Integration name** identifies the sub-integration you\nwant to run.\n\nThe task also lets you collect the response from each sub-integration run and store the value in your\ncurrent integration for use in downstream tasks. You can use any of the following approach to collect the responses:\n\n- Collate the response of each run in an array variable, where each element of the array has the response from one particular run. To collate the responses, configure the `Collect values from sub-integration output(s)` property.\n- Aggregate the responses of all the runs in a single variable. To aggregate the responses, configure the `Override values from sub-integration output(s)` property.\n\n| **Note** :\n|\n| - The **While Loop** task can run a maximum of 8000 iterations. This constraint holds good even if the configured condition results in an infinte loop.\n| - The cumulative size of the data collected from each sub-integration run cannot exceed `50 MB`. If the size exceeds `50 MB`, the integration fails, and the downstream tasks are not run.\n\nBefore you begin\n----------------\n\n- Ensure that you have [attached a user-managed service account](/application-integration/docs/access-control#add-service-account) to your integration. If your integration does not have user-managed service account configured, then by default the [default service account](/application-integration/docs/access-control#default-service-account) (`service-`\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e`@gcp-sa-integrations.iam.gserviceaccount.com`) is used for authentication.\n- Ensure that your service account has the **Application Integration Invoker** IAM role. For information about granting roles to a service account, see [Manage access to service accounts](/iam/docs/manage-access-service-accounts).\n\nConfiguration properties\n------------------------\n\n\nThe following table describes the configuration properties of the **While Loop** task.\n\nBest practices\n--------------\n\nFor information about the usage limits that apply to the **While Loop** task, see [Usage limits](/application-integration/docs/quotas#usage-limits).\n\nError handling strategy\n-----------------------\n\n\nAn error handling strategy for a task specifies the action to take if the task fails due to a [temporary error](/application-integration/docs/error-handling). For information about how to use an error handling strategy, and to know about the different types of error handling strategies, see [Error handling strategies](/application-integration/docs/error-handling-strategy).\n\nQuotas and limits\n-----------------\n\nFor information about quotas and limits, see [Quotas and limits](/application-integration/docs/quotas).\n\nWhat's next\n-----------\n\n- Learn about [all tasks and triggers](/application-integration/docs/all-triggers-tasks).\n- Learn how to [test and publish an integration](/application-integration/docs/test-publish-integrations).\n\n- Learn about [error handling](/application-integration/docs/error-handling-strategy).\n- Learn about [integration execution logs](/application-integration/docs/introduction-logs)."]]