1

NetSuite newbie here.

I have a SuiteScript that loads the results of a sales order query and then creates a work order for each of those results.

Is it possible to also create sublist items in the same stroke or will I have to load each new workorder and then create it that way? If so, any code samples for that? My little script is below.

I have attempted things with insertLineItem and nlapiSelectNewLineItem but no luck so far.

Thanks!

function example1() {

    var arrSearchResults = nlapiSearchRecord(null, 'searchID', null,
            null);

    for ( var i 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';

}
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48
dah97765
  • 679
  • 1
  • 13
  • 29

1 Answers1

0

Your approach is pretty good and there is no way to update everything in one shot analogous to a SQL statement or something.

The only thing I see about your SuiteScript is that two parts would be in a different order. You'd create your sublist records then you have to submit the sublist. After submitting the sublist then you submit the work order.

So like this:

    ... snipped above no changes

    // recWorkOrder.setFieldValue('options', internalId);

    //Create sublist items here?

    //Submit the sublist records

    //Submit the work order last to finalize the transaction 
    nlapiSubmitRecord(recWorkOrder);

  }

  var kilroy = 'was here';
}
Rich Bianco
  • 4,141
  • 3
  • 29
  • 48