ServiceNow Learning 69: Request: Pagination Setup Step in ServiceNow

Shamma Negi
Kilo Sage
Kilo Sage

Hi All,

 

This is about Pagination setup in ServiceNow API. Please have a look at the detailed steps below:

 

Use the Pagination Setup step to provide values for the dynamically determined part of an API request. For example, requests to APIs that return paginated data typically require specifying which page of data to send.

 

Variables of Pagination:

 

Paginated APIs send data one page at a time. Use the Pagination Variables to set values for the options required by the API.

The getNextPage variable is read-only and is part of every Pagination Setup step. The getNextPage variable determines whether to request another page from the API. To avoid infinite loops, the getNextPage variable's default value is false. When the getNextPage variable value is true, the Data Stream Action continues to make API requests.

Developers can click the View Templates button to apply Pagination Variable templates that insert commonly used variables such as limit and offset. To create Pagination Variables, click the Add button (

 

).

 

ShammaNegi_4-1700558299497.png

 

 

Configure the Pagination Variables.

  • Name: Property name for the variable in the variables object.
  • Initial Value: Value of the property in the variables object, the first time an API request is made. The value can be hard-coded, a data pill, or a combination of hardcoding and data pills.
  • Next Value From: Choose Script or Response Body.
    • Script: The Pagination Variables Script determines the value the property will have the next time an API request is made.
    • Response Body: A parsed value from the last API request's response body determines the value the property will have the next time an API request is made.

Pagination Variables Script

The Pagination Variables script is a server-side script where script logic is executed after each API call. The Pagination Variables Script's purpose is to:

  • Set values for any Pagination Variable with Next Value From value of Script.
  • Set the getNextPage Pagination Variable value to false when there are no more pages to request.

The Pagination Variables Script is passed two objects:

  • variables: Properties are the Pagination Variables.
  • pageResponse: Response body from the previous API call.

ShammaNegi_5-1700558328141.png

 

 

TIP: Pagination Variables and anything parsed from the pageResponse are strings. In Pagination Variables Scripts, typecasting may be required to ensure the correct data type for mathematical or other operations.

 

 

Helpful Link : How to quickly setup new data stream action with pagination - Support and Troubleshooting (serviceno...

 

 

Hope this helps.

I hope this article helpful. Please mark it as helpful and bookmark if you like it.

 

Regards,

Shamma

--The WIN is coming. Don't let the WHEN worry you!

 

Regards,Shamma Negi
0 REPLIES 0