Different methods to fetch the Query search result

Run the Query search to get the result

This will return a maximum of 5000 results.

 var resultSet = requisitionQuery.run();
let resultasObject= resultSet.asMappedResults();// return the result as array of object. Where the key in the object will be the alias or fieldid and the value will be the field value.

Paginated Query search result

The result will be paginated. The maximum size of the result on a page can be 1000.

 let pagedData = requisitionQuery.runPaged({
                    pageSize: 1000
                });
                log.debug('pagedData.pageRanges', pagedData.pageRanges)
                pagedData.pageRanges.forEach((pageRange) => {
                    let page = pagedData.fetch({ index: pageRange.index });
                    page.data.results.forEach((result) => {
                        requisitions.push(result.asMap());// return the result as array of object. Where the key in the object will be the alias and the value will be the field value.
                    });
                });

Leave a comment

Your email address will not be published. Required fields are marked *