Hello, I am l getting an unexpected error when try...
# suitescript
p
Hello, I am l getting an unexpected error when trying to batch delete out the saved searches from a map/reduce script. Can you tell me what I am doing wrong? log.debug('In Map Stage'); var searchResult = JSON.parse(context.value); log.debug({ title: 'The Search Result', details: searchResult }); //log.debug('searchResult is '+searchResult ); var coid = searchResult.id; var idofsearch = searchResult.values["custrecord_pi_intidrecord"]; var recordtype = searchResult.values["custrecord_pi_recordtype"]; log.debug('idofsearch is '+idofsearch); log.debug('recordtype is '+recordtype); //submit field, update the status of the WO to Released try { /*var mySearch = search.load({ id: idofsearch });*/ //log.debug('mySearch '+ mySearch); var mySearch = search.delete({ id: idofsearch });
s
@Phillip Try deleting without loading the search? What is the reason for deleting a search in a MR script?
p
I need to delete out 200 saved searches. I commented out the load and it is still throwing an unexpected error
s
Are these saved searches stored in a custom record type? Does the record need to be deleted first, before the saved search?
p
the record does not need to be deleted and they are stored in a custom record type
s
Are you sure your results are coming back as the
customsearch_id
or the actual internalid (number)? The help indicates it needs to be the
customsearch_id
version, might wanna double check you have the right id
p
whats the customsearch_id search version
ok
got it. I have tried passing in customsearch443 and the internal id of the search 443
s
@Phillip try running the delete in the console and confirm it’s working as expected. Then run it in the SuiteScript Debugger, and then again in the M/R script. If this is a bug, NetSuite will ask you do that (and more) before they do anything about it anyway.
p
thank you