La tarea Para cada bucle te permite realizar llamadas repetidas a una integración secundaria desde tu integración actual (principal). La tarea se itera en la variable de array configurada y llama a la subintegración para cada elemento del array. La cantidad de veces que se llama a la subintegración es igual al tamaño de la variable del array.
El ID del activador de la API y el Nombre de la integración identifican la subintegración que deseas ejecutar.
La tarea también te permite recopilar la respuesta de cada ejecución de la subintegración y almacenar el valor en tu integración actual para su uso en tareas posteriores. Puedes usar cualquiera de los siguientes enfoques para recopilar las respuestas:
Intercala la respuesta de cada ejecución en una variable de array, en la que cada elemento del arreglo tiene la respuesta de una ejecución en particular. Para recopilar las respuestas, configura la propiedad Collect values from sub-integration output(s).
Agrega las respuestas de todas las ejecuciones en una sola variable. Para agregar las respuestas, configura la propiedad Response parameter override mapping.
Asegúrate de que tu cuenta de servicio tenga el rol de IAM Invocador de Application Integration. Para obtener información sobre cómo otorgar roles a una cuenta de servicio, consulta Administra el acceso a las cuentas de servicio.
Propiedades de configuración
En la siguiente tabla, se describen las propiedades de configuración de la tarea Para cada bucle.
Propiedad
Tipo de datos
Descripción
API Trigger ID
String
El ID del activador de la integración secundaria que se ejecutará.
Este valor está disponible en el campo ID del activador del activador de API en la integración secundaria.
Integration name
String
Nombre de la subintegración que se ejecutará.
List to iterate
Un array del tipo booleano, string, número entero, doble o JSON
Lista de valores para los que se deben ejecutar la subintegración. La subintegración se ejecuta para cada valor de la lista, uno después del otro.
Puedes pasar el valor iterado a la subintegración si configuras la propiedad asignación de subintegración de elementos de iteración. En esta propiedad, especifica la variable en la subintegración a la que se debe asignar el valor iterado.
Iteration element sub-integration mapping
N/A
Variable en la subintegración para la que se debe asignar el elemento iterativo actual.
Map to additional sub-integration input(s)
N/A
Son valores adicionales que se pasarán de la integración actual a la subintegración.
Los valores de esta propiedad tienen el formato de pares clave-valor, en los que la clave es una variable en la integración actual y el valor es la variable de entrada correspondiente en la subintegración. Por ejemplo, supongamos que tu integración principal tiene la variable productID, que deseas asignar a la variable de subintegración subIntProductID. Deberías seleccionar productID desde el menú desplegable Integration variable to map from y selecciona subIntProductID del menú desplegable Subintegration input to map to.
Collect values from sub-integration output(s)
N/A
Intercala los resultados de las ejecuciones de la subintegración.
Cada vez que se ejecuta la subintegración, puedes almacenar su resultado en una variable de array de la integración actual.
Selecciona la variable de salida de la subintegración desde el menú desplegable Sub-integration output to collect from y la variable de array en la integración actual desde el menú desplegable Integration variable to collect into. Cada elemento del array tiene la respuesta de una ejecución de subintegración en particular. Por ejemplo, si la variable de array es resultsArray, resultsArray[0] tiene la respuesta de la primera ejecución y resultsArray[1] tiene la respuesta de la segunda ejecución.
Response parameter override mapping
N/A
Lee la variable de salida de una ejecución de subintegración y almacénala en una variable de la integración actual.
Selecciona la variable de resultado de la subintegración en el menú desplegable Sub-integration output to map from y selecciona la variable correspondiente en la integración actual del menú desplegable Integration variable to override. Puedes enviar la variable anulada en la integración actual a la siguiente ejecución de subintegración si asignas la variable en la propiedad Map to additional sub-integration input(s). Como resultado, puedes agregar las respuestas de las ejecuciones de subintegración de forma acumulativa.
Loop metadata
Arreglo JSON
La variable de resultado que tiene los detalles de ejecución de las subintegraciones, como el ID de ejecución de la subintegración, los mensajes de error y los valores de las variables que se pasaron durante la ejecución. Los metadatos del bucle contienen variables, incluidas las siguientes variables de salida: current_iteration_count, sub_integration_execution_ids, failure_location, current_element, iteration_element y failure_message.
Prácticas recomendadas
Para obtener más información sobre los límites de uso que se aplican a la tarea Para cada bucle, consulta Límites de uso.
Estrategia de manejo de errores
Una estrategia de manejo de errores de una tarea específica la acción que se debe realizar si la tarea falla debido a un error temporal. Para obtener información sobre cómo usar una estrategia de manejo de errores y conocer los diferentes tipos de estrategias de manejo de errores, consulta Estrategias de manejo de errores.
Cuotas y límites
Para obtener más información sobre las cuotas y los límites, consulta Cuotas y límites.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-03 (UTC)"],[[["\u003cp\u003eThe For Each Loop task allows repeated execution of a sub-integration for each element within an array variable, where the number of iterations equals the array's size.\u003c/p\u003e\n"],["\u003cp\u003eSub-integrations are identified by their API Trigger ID and Integration name, and the task provides mechanisms to collect and utilize responses from each sub-integration run, including collating into an array or aggregating into a single variable.\u003c/p\u003e\n"],["\u003cp\u003eThe For Each Loop task has limits, including a maximum of 8000 iterations and a cumulative data collection size limit of 50 MB across all sub-integration runs.\u003c/p\u003e\n"],["\u003cp\u003eFailure of any sub-integration run within the For Each Loop task results in the failure of the entire task, though this can be mitigated through the use of an Execution strategy in the Join configuration.\u003c/p\u003e\n"],["\u003cp\u003eProper setup requires ensuring a user-managed service account is attached to the integration, with the service account having the necessary Application Integration Invoker IAM role.\u003c/p\u003e\n"]]],[],null,["# For Each Loop task\n\nSee the [supported connectors](/integration-connectors/docs/connector-reference-overview) for Application Integration.\n\nFor Each Loop task\n==================\n\nThe **For Each Loop** task lets you make repeated calls to a sub-integration from\nyour current (main) integration. The task iterates over the configured array variable and calls\nthe sub-integration for each element in the array. The number of times\nthe sub-integration is called is equal to the size of the array variable.\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 `Response parameter override mapping` property.\n\n| **Note** :\n|\n| - A **For Each Loop** task can run a maximum of 8000 iterations.\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| - If an integration in the **For Each Loop** task fails, then the entire task fails, and the downstream tasks are not run. To prevent failure of the entire integration you can specify an **Execution strategy** for the task in its *Join configuration pane* . See [Join](/application-integration/docs/forks-joins#join) for more details.\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 **For Each Loop** task.\n\nBest practices\n--------------\n\nFor information about the usage limits that apply to the **For Each 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)."]]