wilberforce wairagu
06/16/2023, 12:22 PMNathan L
06/16/2023, 12:44 PMsearch.load({id: request.searchId, type: request.searchType})
Then in your request payload you send to the RESTlet, add in the search type parameter.Nathan L
06/16/2023, 12:45 PMwilberforce wairagu
06/16/2023, 12:53 PMNathan L
06/16/2023, 1:39 PMcurl -X "POST" "<https://tstdrv2355109.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=899&deploy=1>" \
-H 'Content-Type: application/json' \
-H 'Authorization: OAuth oauth_consumer_key="7d2c8326a648d4ac7e3013bb492a4a77570677ac2bdba24b30cc24d3dfae722e", oauth_nonce="U8mgCkrNJa5evQdh7ARaoxERtE2beDVr", oauth_signature="Ao4sydHcRTXMPqhzkv8k%2B12NS%2FbzicaqX1js02UlrSM%3D", oauth_signature_method="HMAC-SHA256", oauth_timestamp="1633340518", oauth_token="029e4df8d69a6ad6313e732cd59dccbd430096e4d6c3ed773c24e2ff6321a842", oauth_version="1.0", realm=TSTDRV2355109' \
-H 'Cookie: NS_ROUTING_VERSION=LAGGING' \
-d $'{
"searchID": "customsearch_esc_my_customers_2",
"searchType": "some_record_type_here"
}'
Then your restlet should look something like this
function postProcess( request ) {
try {
if ( ( typeof request.searchID == 'undefined' ) || ( request.searchID === null ) || ( request.searchID == '' ) ) {
throw { 'type': 'error.SavedSearchAPIError', 'name': 'INVALID_REQUEST', 'message': 'No searchID was specified.' }
}
// here is where we updated the code to match the new payload
var searchObj = search.load( { id: request.searchID, type: request.searchType } );
response.results = [];
var resultSet = searchObj.run();
var start = 0;
var results = [];
do {
results = resultSet.getRange( { start: start, end: start + 1000 } );
start += 1000;
response.results = response.results.concat( results ) ;
} while ( results.length );
return response;
} catch( e ) {
log.debug( { 'title': 'error', 'details': e } );
return { 'error': { 'type': e.type, 'name': e.name, 'message': e.message } }
}
}
wilberforce wairagu
06/16/2023, 1:49 PMreptar
06/16/2023, 1:57 PMNathan L
06/16/2023, 2:00 PMNathan L
06/16/2023, 2:01 PMbattk
06/16/2023, 2:09 PMbattk
06/16/2023, 2:10 PMwilberforce wairagu
06/16/2023, 2:11 PMbattk
06/16/2023, 2:11 PMbattk
06/16/2023, 2:11 PMwilberforce wairagu
06/16/2023, 2:12 PMwilberforce wairagu
06/16/2023, 2:12 PMNathan L
06/16/2023, 2:13 PMNathan L
06/16/2023, 2:13 PM