Hello. When we write RESTlet, if we are creating 1...
# suitescript
b
Hello. When we write RESTlet, if we are creating 100 SOs it usually take more than 5 minutes which is the limit of Restlet. I know I should use MR script but I want to return SO Ids after Sales Orders are created. In this case could I know how to do this in Restlet please?
b
implement paging, instead of sending 100 sales orders per request to be created at a time, send 10 at a time, or whatever number you deem safe
plusone 1
r
If you can do map request for it you can write the created sales order ids created to the the summary and then when they’re all done you have an array of sales orders created?
Something like this. /** ◦ @NApiVersion 2.1 ◦ @NScriptType MapReduceScript */ define(['N/record', 'N/search', 'N/log'], (record, search, log) => { const map = (context) => { let searchResult = JSON.parse(context.value); let someDataToPass = { id: searchResult.id, value: searchResult.values.someField }; // Writing data to context to be used in the summarize stage context.write({ key: searchResult.id, value: someDataToPass }); }; const summarize = (summaryContext) => { summaryContext.output.iterator().each((key, value) => { // Process the data aggregated from the map stage log.debug({ title: 'Processing ID: ' + key, details: 'Value: ' + value }); return true; }); }; return { map, summarize }; });