If we have to obtain more than 5000 queries using a SuiteQL query, we will have to use SuiteQL.runPaged() function.
For example, here we are trying to obtain the internal ID and subject of all phone call records that are assigned to the employee with internal ID -5 :
let suiteql =`SELECT id, title FROM phonecall WHERE assigned = -5`
let queryPaged = query.runSuiteQLPaged({
query: suiteql,
pageSize: 4000 // Set page size to handle up to 4000 results per page
});
queryPaged.pageRanges.forEach(function (pageRange) {
let page = queryPaged.fetch({ index: pageRange.index });
let queryResults = page.data.asMappedResults();
queryResults.forEach(result => {
let internalid = result.id;
let title= result.title;
console.log(“Internal Id: “+internalid, “title: “+title);
});
});