La tarea Bucle While te permite hacer llamadas repetidas a una subintegración desde tu integración actual (principal) hasta que se cumpla una condición especificada.
El ID de activación de la API y el nombre de la integración identifican la subintegración que quieres ejecutar.
La tarea también te permite recoger la respuesta de cada ejecución de subintegración y almacenar el valor en tu integración actual para usarlo en tareas posteriores. Puedes usar cualquiera de los siguientes métodos para recoger las respuestas:
Recopila la respuesta de cada ejecución en una variable de matriz, donde cada elemento de la matriz tiene la respuesta de una ejecución concreta. 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 Override values from sub-integration output(s).
Asegúrate de que tu cuenta de servicio tenga el rol de gestión de identidades y accesos Invocador de integración de aplicaciones. Para obtener información sobre cómo conceder roles a una cuenta de servicio, consulta el artículo sobre cómo gestionar el acceso a cuentas de servicio.
Propiedades de configuración
En la siguiente tabla se describen las propiedades de configuración de la tarea Bucle while.
Propiedad
Data type (Dato)
Descripción
API Trigger ID
Cadena
ID de activación de la subintegración que se va a ejecutar.
Este valor está disponible en el campo ID de activador del Activador de API
de la subintegración.
Integration name
Cadena
Nombre de la subintegración que se va a ejecutar.
While loop condition
N/A
Condición para terminar el bucle. La subintegración se ejecuta hasta que se cumple la condición. Por ejemplo, $loopMetadata.current_iteration_count$< 10.
Map to sub-integration input(s)
N/A
Valores que se van a transferir de la integración actual a la subintegración.
Los valores de esta propiedad tienen la forma de pares clave-valor, donde la clave es una variable de la integración actual y el valor es la variable de entrada correspondiente de la subintegración. Por ejemplo, supongamos que tu integración principal tiene la variable productID
y quieres asignarla a la variable subIntProductID de la subintegración. Para ello, selecciona productID en el menú desplegable Variable de integración que se va a asignar e introduce subIntProductID en el campo Variable de subintegración a la que se va a asignar.
Collect values from sub-integration output(s)
N/A
Recopila los resultados de las ejecuciones de la subintegración.
Cada vez que se ejecute la subintegración,
puedes almacenar su salida en una variable de matriz de la integración actual. Introduce la variable de salida de la subintegración en el campo Variable de salida de la subintegración que se va a recoger y selecciona la variable de matriz de la integración actual en el desplegable Variable de integración en la que se va a recoger. Cada elemento de la matriz tiene la respuesta de una ejecución de subintegración concreta. Por ejemplo, si la variable de matriz es resultsArray,
resultsArray[0] tiene la respuesta de la primera ejecución y resultsArray[1] tiene
la respuesta de la segunda ejecución.
Override values from sub-integration output(s)
N/A
Lee la variable de salida de una ejecución de una subintegración y guárdala en una variable de la integración actual.
Seleccione la variable de salida de la subintegración en el menú desplegable Variable de salida de la subintegración que se va a asignar y, a continuación, seleccione la variable correspondiente de la integración actual en el menú desplegable Variable de integración que se va a sustituir. Puedes enviar la variable sustituida en la integración actual
a la siguiente subintegración asignando la variable en la propiedad Asignar a subintegraciones adicionales. Por lo tanto, puedes agregar de forma acumulativa las respuestas de las ejecuciones de la subintegración.
Loop metadata
Matriz JSON
Variable de salida que contiene los detalles de ejecución de las ejecuciones de la subintegración, como el ID de ejecución de la subintegración, los mensajes de error y los valores de las variables transferidos durante la ejecución. Los metadatos de 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 información sobre los límites de uso que se aplican a la tarea Bucle While, consulta Límites de uso.
Estrategia de gestión de errores
Una estrategia de gestión de errores de una tarea especifica la acción que se debe llevar a cabo si la tarea falla debido a un error temporal. Para obtener información sobre cómo usar una estrategia de gestión de errores y conocer los diferentes tipos de estrategias de gestión de errores, consulta Estrategias de gestión de errores.
Cuotas y límites
Para obtener información sobre las cuotas y los límites, consulta Cuotas y límites.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-11 (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)."]]