Search code examples
netsuitesuitescriptsuitetalk

How to get newly created sales order internal id in suitescript 2.0?


I'm writing a suitescript to send order details to a customer email address.

Is it possible to get the sales order id through scriptContext or similar method?

My function is run on Sales Order After Submit.

function afterSubmit(scriptContext){

     soid = scriptContext.soid; //<--trying to get the sales order id

}

Solution

  • In an afterSubmit, you can use scriptContext.newRecord.id.

    See afterSubmit documentation here: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4407992281.html

    and record.Record object members documentation here: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4267255811.html#bridgehead_4273190849