Paginate

This function card is only available in Workflows Connector Builder.

Use a helper flow to paginate through multiple pages of an HTTP response.

For additional best practices when using the Paginate function card, see:

Overview

The internal paginate function that exists in Workflows today is essentially a Do While loop that looks for a break keyword in order to decide whether to keep looping. When the loop starts, an object is passed into the Object field of the function, and the values within that object are managed within a helper flow. As the values in that object get updated, they are returned to the function and the object again gets passed back into the helper flow with the updated values.

Proper use of the break field is very important to the paginate function. If it is not used properly, the flow could run until the platform hits a maximum count of 5,000 iterations. In order to stop the iteration, the break field must be removed from the object.

Input

Field Definition Type Required
Object Object passed into the helper flow. This can hold any number of keys and values such as offset, page_index, url, and a list object used to collect records. It is required that there is a key that represents the break to tell the function when to stop iterating. It should be initially set to false. Object TRUE
Path Key for the field in the Object input to monitor for when to stop the loop. This is commonly called break, and it should be initially set to FALSE. In order to stop the iteration, the break field must be removed from the Object input. Text TRUE
Helper Flow Flow used to process the object passed into the Object input field. Flow TRUE

Output

Field Definition Type
Output

Object containing the new values.

Object

Basic Example

In this example, you want to iterate only a certain number of times. This should be your first task when you begin working with pagination and will help with testing your flows. You will need to create an object with three values that will get passed to your helper flow. These are examples of key names:

  • page_index: Current count of iterations.

  • max_page_index: Maximum number of times that the helper flow should iterate.

  • break: Value to monitor for when to stop the loop.

Copy
{
    “page_index”: 0,
    “max_page_index”: 10,
    “break”: false
}

In the helper flow, the inputs that you defined on the event card will need to match the keys defined in the object above: page_index, max_page_index, and break. You can then use these within your flow. You can use the Number Add function card to increase the page_index on each iteration, and return that new number to the Paginate function card.

Copy
{
    “page_index”: 1,
    “max_page_index”: 10,
    “break”: false
}

The counter will increase as the flow continues to iterate. Once page_index hits 10, the break condition should be removed from the object to stop the iteration.

Copy
{
    “page_index”: 10,
    “max_page_index”: 10,
}

Related topics

Paginate: Set a Max Page Index

Paginate: API Endpoint

Functions in Workflows

About the elements of Okta Workflows