Using Do While Loop Logic in Integration Workflows

You can call actions inside Do While Loop logic sequences to ensure the action is executed at least once so you'll be able to specify the condition(s) when the loop execution should cease.

Important:

The iteration limit for Do While Loop logic is 1000 attempts for a single integration event. Once exceeded, the system will fail the workflow and throw an error.

To bypass the Apply to Each and Do While Loop constraints, users can leverage the subflow action or a generic POST request to effectively chain multiple integration workflows, known as the “workflow chaining” approach. This approach involves triggering another workflow’s webhook trigger and passing the necessary data in the API call’s body.

To configure Do While Loop logic

  1. On the Integrations menu, select Integrations.

    The Integrations screen appears.

  2. Click on the name of a workflow.

    The Integration Builder screen appears.

  3. Configure the workflow with an initial trigger.
  4. Click the Add Action button.
  5. Click the Logic tab, then click Do While Loop.


  6. Select and configure the action(s) as necessary, then click the Finish button. Once you've added an action, you can now add one or more While conditions.
    Note:

    There must be at least one action present under the Do action in order to edit the While action.





  7. Click the Edit icon on the While action.
  8. Specify the conditions with values and operators upon which the prior Do action should execute. Use the Plus icon to add additional criteria conditions.
    Note:

    The While action must have at least one condition in order to click Done and close the logic action.



  9. Click the Done button.
  10. Configure the rest of the workflow as necessary, then click the Save button.

To delete Do While Loop logic

  1. On the Integration Builder screen, click the Trash icon on the Do action.

    The Delete Action modal appears.

  2. Click the Confirm button to delete the action. The entire Do While Loop sequence will be deleted.


Combining with Apply to Each Logic for Pagination

You can also include Apply to Each logic within a Do While Loop sequence to support next link-based pagination and token-based pagination use cases.

The workflow here includes an Apply to Each step with a nested POST action and a Data Transformation step, all of which is nested under the Do step. The workflow ends with the While step to close the loop.



Within this Apply to Each step a value is selected to loop through each element in the given page of results, which in this case is Office 365 posting to an API call to scan for personally identifiable information (PII).



Next, the Data Transformation is acting upon the response produced by the Apply to Each logic. This stores the next link provided by the GET User Emails call so that the next pass through the loop this URL will get the next page of data.



Finally, the While step specifies the cease conditions for when the execution sequence should stop. In this reference, if no link is returned by the Data Transformation, then the nextPageLink variable is set to NOMORE so it's known if there are no more pages. The While condition checks that nexPageLink does not equal NOMORE so the workflow knows to call the API again to get more emails.