Need help to build script for pagination rest message integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2024 06:31 AM - edited ‎08-23-2024 04:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 06:51 AM
first you should know how many total records are there. Based on that you can have the loop defined based on the chunk
Logic will be
1) make an API call to get the total count example: 359
2) loop for total/300 number of times -> 359/300 -> 2 times
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 07:27 AM
Hello Ankur,
Thanks for the reply.
There are 359 total records. Currently, everything works perfectly; I triggered the rest message twice, the first returning 300 and the second adding offset 300, so I received the remaining 59. However, I wanted to make this dynamic so that it would work in the future until all records were returned. And I tried so many ways to do the loop but not success. I need assistance here. The third rest message must be sent to office 359, so it will return 0 records for this time and loop will stop. Please help me create a loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 07:37 AM
Did you check the steps I mentioned?
something like this
// make API call to know the total count
var totalCount = 359;
var offset = 300;
var loopCount = Math.ceil(359/300);
for(var i=0;i<loopCount;i++){
// your API call
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2024 11:59 PM
Thanks for you time.
I believe there might be a misunderstanding. Could you kindly review this message when you have a moment?