Ben Tanner
04/14/2023, 6:48 PMquery.runSuiteQLPaged
throws the "Search error occurred: Invalid or unsupported search" error. The same query is successful using query.runSuiteQL
but does not include all results, hence the need to run paged. I'm not sure what the difference is. Any troubleshooting tips?Clay Roper
04/14/2023, 8:00 PMORDER BY
?Ben Tanner
04/14/2023, 8:29 PMraghav
04/14/2023, 8:55 PMvar allResults = [];
var paginatedRowBegin = 0;
var paginatedRowEnd = 5000;
var moreRecordsFlag = true;
while(moreRecordsFlag) {
var paginatedSQL = 'SELECT * FROM ( SELECT ROWNUM AS ROWNUMBER, * FROM ( ' + queryString + ' ) ) WHERE ( ROWNUMBER BETWEEN ' + paginatedRowBegin + ' AND ' + paginatedRowEnd + ')';
var results = query.runSuiteQL({query: paginatedSQL} ).asMappedResults();
allResults = allResults.concat( results );
if ( results.length < 5000 ) {
moreRecordsFlag = false;
}
paginatedRowBegin = paginatedRowBegin + 5000;
paginatedRowEnd = paginatedRowEnd + 5000;
} log.debug("allResults",allResults.length);
Ben Tanner
04/14/2023, 8:59 PMClay Roper
04/14/2023, 9:02 PMBen Tanner
04/14/2023, 9:05 PMraghav
04/14/2023, 9:15 PMBen Tanner
04/14/2023, 9:20 PMClay Roper
04/14/2023, 9:21 PMBen Tanner
04/14/2023, 9:25 PMselect e.LASTNAME
, e.FIRSTNAME
, e.entityid
, e.TITLE
, csm.NAME as role
, e.EMAIL
, d.FULLNAME as department
, a.STATE
, c.entitySTATUS as customer_status
, c.ID as customer_id
, mc.custrecord_mdl_cloud_site_code
from Customer c
inner join CustomerSubsidiaryRelationship sub on sub.isprimarysub = 'T' and sub.subsidiary = 2 and sub.entity = c.id
inner join CUSTOMRECORD_MDL_CLOUD mc on mc.custrecord_mdl_cloud_customer = c.id and mc.ISINACTIVE = 'F' and UPPER(mc.custrecord_mdl_cloud_site_code) not like '%CLOSED%' and UPPER(mc.custrecord_mdl_cloud_site_code) not like '%DISABLED%'
inner join EMPLOYEE e on e.ISINACTIVE = 'F' and e.SUBSIDIARY = 2 and (c.custentity_noncorecsm3 = e.id or c.custentity_noncorecsm4 = e.id)
inner join DEPARTMENT d on d.id = e.DEPARTMENT
left outer join CUSTOMLIST_SUPPORTROLES csm on csm.id = e.custentity_supportrole
left outer join customerAddressbookEntityAddress a on a.nkey = c.defaultbillingaddress
where c.entitystatus not in (16,17,69)
UNION ALL
select e.LASTNAME
, e.FIRSTNAME
, e.entityid
, e.TITLE
, sr.NAME as role
, e.EMAIL
, d.FULLNAME as department
, a.STATE
, c.entitySTATUS as customer_status
, c.ID as customer_id
, mc.custrecord_mdl_cloud_site_code
from Customer c
inner join CustomerSubsidiaryRelationship sub on sub.isprimarysub = 'T' and sub.subsidiary = 2 and sub.entity = c.id
inner join CUSTOMRECORD_MDL_CLOUD mc on mc.custrecord_mdl_cloud_customer = c.id and mc.ISINACTIVE = 'F' and UPPER(mc.custrecord_mdl_cloud_site_code) not like '%CLOSED%' and UPPER(mc.custrecord_mdl_cloud_site_code) not like '%DISABLED%'
inner join CustomerSalesTeam st on st.customer = c.id
inner join EMPLOYEE e on e.ISINACTIVE = 'F' and e.SUBSIDIARY = 2 and e.id = st.employee
inner join DEPARTMENT d on d.id = e.DEPARTMENT
inner join salesRole sr on sr.id = st.salesrole
left outer join customerAddressbookEntityAddress a on a.nkey = c.defaultbillingaddress
where c.entitystatus not in (16,17,69)