Paginate Records in a Table in Okta Workflows (Recursion example)

In this guide:

  1. Okta Workflows guides
  2. Paginate a table
  3. Related Okta Workflows guides
  4. Okta Workflows resources

Okta Workflows guides

Okta Workflows guides are questions and answers from the community office hours, the #okta-workflows channel on MacAdmins Slack, and other places. Read all the other guides.

How do you paginate records in a table in Okta Workflows?

This guide will teach you how to paginate a table with more than 3,500 records in Okta Workflows.

Paginate a table

The Tables—Search Rows card returns 3,500 rows (records) from a table. If a table has more than 3,500 records, you must paginate the result to retrieve all the records.

The solution has two flows:

  • Main.
  • Paginate table.

Table

This example uses the Countries table with 249 countries and a page size of 50.

Country table.
Country table.

Main flow

The Main flow starts the pagination. The flow has two inputs:

  • Limit: How many records are to be returned (per page).
  • Offset: at which record should the search start.
Main flow to start pagination.
Main flow to start pagination.
  1. The Call Flow card starts the pagination. It requests the first 50 records from a table.
    • After paginating through all the table records, the Result field holds all the records from the table.
  2. The List—Length card shows the number of records in the list (which also shows the number of records in a table).

Paginate table flow

The Paginate table flow retrieves 50 records until there are no more records in the table.

Paginate table flow.
Paginate table flow.
  1. The Helper Flow card starts this flow.
  2. The Tables—Search Rows card retrieves table records using the Limit and Offset fields.
  3. The List-Length card calculates the list size from the previous stop.
  4. The Branching—If/Else card
    • If Row count < Limit (if there are less than 50 records), these are the last records, and nothing else to retrieve after this stop.
    • Else (there are more than 50 records)
      • The Number—Add card calculates the next Offset. It adds 50 to the current Offset to show the next 50 records.
      • The flow recursively calls the Call Flow card, passing the new Offset value.
      • The List—Combine All card combines the records from current and child results.
  5. The Flow Control—Return card returns all the records to the Main flow.

The following shows the recursive calls and how the calls return data.

  • Execution 1 starts with Offset=0
  • Execution 1 does a query, gets rows 1-50
  • Execution 1 does a recursive Call Flow
    • Execution 2 starts with Offset=50
    • Execution 2 does a query, get rows 51-100
    • Exec2 does a recursive Call Flow
      • Execution 3 starts with Offset=100
      • Execution 3 does a query, gets rows 101-150
      • Execution 3 does a recursive Call Flow
        • Execution 4 starts with Offset=150
        • Execution 4 does a query, gets rows 151-200
        • Execution 4 does a recursive Call Flow
          • Execution 5 starts with Offset=200
          • Execution 5 does a query, gets rows 201-249
          • Execution 5 sees there are no more records and returns an array with rows 201-249
        • Execution 4 combines its results with the child’s results
        • Execution 4 returns an array with rows 151-249
      • Execution 3 combines its results with the child’s results
      • Execution 3 returns an array with rows 100-249
    • Execution 2 combines its results with the child’s results
    • Execution 2 returns an array with rows 50-249
  • Execution 1 combines its results with the child’s results
  • Execution 1 returns an array with rows 1-249

Template

Download a flow template.Ā 

Okta Workflows resources

šŸ“ŗ Learn from Okta Workflows videos.

ā“Ask questions during Okta Workflows community office hours.

šŸ›Ÿ Ask questions on the Okta Workflows community forum.

šŸ™‹šŸ»ā€ā™€ļø Join the #okta-workflows channel on the MacAdmins Slack to get help from the community.

Leave a comment