NetSuite: Create WorkOrder and Sublist with SuiteScript -


netsuite newbie here.

i have suitescript loads results of sales order query , creates work order each of results.

is possible create sublist items in same stroke or have load each new workorder , create way? if so, code samples that? little script below.

i have attempted things insertlineitem , nlapiselectnewlineitem no luck far.

thanks!

function example1() {      var arrsearchresults = nlapisearchrecord(null, 'searchid', null,             null);      ( var in arrsearchresults) {         var searchresult = arrsearchresults[i];          // create work order records          var recworkorder = nlapicreaterecord('workorder');          recworkorder.setfieldvalue('quantity', '8');         recworkorder.setfieldvalue('assemblyitem', iteminternalid);         // recworkorder.setfieldvalue('options', internalid);          nlapisubmitrecord(recworkorder);          //create sublist items here?      }      var kilroy = 'was here';  } 

your approach pretty , there no way update in 1 shot analogous sql statement or something.

the thing see suitescript 2 parts in different order. you'd create sublist records have submit sublist. after submitting sublist submit work order.

so this:

    ... snipped above no changes      // recworkorder.setfieldvalue('options', internalid);      //create sublist items here?      //submit sublist records      //submit work order last finalize transaction      nlapisubmitrecord(recworkorder);    }    var kilroy = 'was here'; }