Pull sales order number from newly created sales order

Viewed 19

When I create a sales order I want to grab the sales order number which is 'To be generated' when inputting a new SO.

I have tried using the after submit function on a UserEventScript but the value still returns null when saving a new SO.

The only way I have been able to get the SO# is to save the record and then go back int edit on that record but this is not useful to me.

1 Answers

Within a User Event script type, afterSubmit function use the following code:

var recId= scriptContext.newRecord.id;      
var soRec = record.load({
    type: record.Type.SALES_ORDER, 
    id: rec_id
});
var soNumber = rec.getValue({fieldId: 'tranid'});
// or get Text
var soText = rec.getText({fieldId: 'tranid'});
Related