Paginate: Set a Max Page Index

This function card is only available in Connector Builder.

When working with the Paginate function card, it’s important to have control over how many times the function will iterate. The Workflows platform has a maximum iteration count of 5000 on this function, and being able to reduce that while testing flows is extremely important. This example will show how to set a max_page_index of 10 and halt pagination once that index has been reached. This should be your first task when working with pagination in Workflows.

See Paginate to get started with this function card, and Paginate: API Endpoint for additional best practices when using this card.

First, create an object with three key/value pairs that will get passed into the Paginate function card. This is done using the Object Construct card.

This is the resulting object:

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

The pagination function requires the use of a helper flow, and the inputs defined on the helper flow event card will need to match the keys defined in the pagination object above:

page_index, max_page_index, and break.

The platform will extract the values from the pagination object and make them accessible in the flow.

When the helper flow executes, the values passed into the flow need to be managed. Since the goal is to track the number of iterations made by the pagination function, the index will need to be increased with each iteration. This can be done using the Number Add function. Once the index has been increased, the pagination object needs to be reconstructed so it can be returned to the pagination function.

This is the resulting object:

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

Once index reaches 10, the break condition should be removed from the object to stop the pagination function from iterating again. This can be done using the Branching If/Else function by setting the If condition to index equals max_page_index. Within that condition, the Object Unset function can be used to remove the break key/value pair. The resulting new pagination object is then returned to the parent flow and the pagination will stop.

This is the resulting object:

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

Related topics

Paginate

Paginate: API Endpoint

Functions in Workflows

Workflow elements