Get multiple pages of data in Bridge

Brian_Richardson Overachievers Alumni
edited 10/05/23 in Best Practice

Hi all I just wanted to pass along a pro-tip that I got from the Technical Engineering group at ENGAGE 23.

If you need to deal with paged data in Bridge, it's not immediately obvious how to do that. At least not to me :-) So I asked.

For example, if you do a List Sheets in Bridge, you may get some of the data back on page 1, but the results may tell you that you have 5 pages of data to go. How do you get the next page without hard-coding page numbers into multiple Get Sheet modules?

The answer is: Child Workflow index

When you call a Child Workflow, each time the workflow runs it identifies an index number for that run, starting with index=0 for the first run. You can leverage that for your paging like this:

  1. Do your List Sheets, primarily to get the total number of pages. For List Sheets that reference is {{states.startstate.smartsheet.list_sheets.sheets.totalPages}}
  2. Call a Child Workflow, and set the Number of Runs to the totalPages reference
  3. On the first child workflow run (Page 1), the index will be 0. That index is part of the trigger data on the child workflow. The index reference is {{runtime.index}}
  4. Setup your Child Workflow to increment the index by 1 using the Math:Add module. The Add value is 1. The Number value is {{runtime.index}}. Your resulting reference will be {{states.startstate.maths.add}}. For the first run (Index 0) this value will be 1.
  5. Add the List Sheets module after the Math module in your child workflow. In Page Number put {{states.startstate.maths.add}}.

Using this setup, the parent workflow will call the child to run for as many pages of data as you have in the original results. Then the child will run once for each page, asking for the page number in increments of 1 each time it runs, and will return to you the results for that page.