Clay Roper
03/22/2022, 3:57 PMORDER BY
breaking query.runSuiteQLPaged
?Alan Fitch
03/22/2022, 4:37 PMClay Roper
03/22/2022, 4:54 PMAlan Fitch
03/22/2022, 5:21 PMasMappedResults
paging it manually with a do while
loop makes more sense imhoAlan Fitch
03/22/2022, 5:23 PMvar moreRecords = true;
var paginatedRowBegin = docInfo.rowBegin;
var paginatedRowEnd = docInfo.rowEnd;
var queryParams = new Array();
var records = new Array();
do {
var paginatedSQL = 'SELECT * FROM ( SELECT ROWNUM AS ROWNUMBER, * FROM (' + docInfo.query + ' ) ) WHERE ( ROWNUMBER BETWEEN ' + paginatedRowBegin + ' AND ' + paginatedRowEnd + ')';
var queryResults = query.runSuiteQL( { query: paginatedSQL, params: queryParams } ).asMappedResults();
records = records.concat( queryResults );
if ( queryResults.length < 5000 ) { moreRecords = false; }
paginatedRowBegin = paginatedRowBegin + 5000;
} while ( moreRecords );
I took this from @tdietrich's sql tool.Clay Roper
03/22/2022, 5:57 PMAlan Fitch
03/22/2022, 6:06 PMClay Roper
03/22/2022, 7:28 PMClay Roper
03/23/2022, 9:08 PMrunSuiteQLPaged()
. Again, our query works swiftly as written in runSuiteQL()
, but with the paged method, it breaks. It turns out it's breaking because it's timing out; even though the resultset contains 67 rows, so less than a page, something about the way it's processing the ORDER BY across the primary table in our query causes the paged method to grind to a halt.
We fixed it by taking a cue from the function above and running our ORDER BY on a subquery so it's not trying to manage the full table.
Thanks for the direction! 🙌Alan Fitch
03/23/2022, 9:12 PMtdietrich
03/24/2022, 12:18 AMAlan Fitch
03/24/2022, 12:41 AMTransactionShipment
but on the joins for transactions it lists it?Alan Fitch
03/24/2022, 12:45 AMrecordscatalog/rcendpoint.nl?action=\getRecordTypes&data
and why it's funky this way.tdietrich
03/24/2022, 1:16 AM