Reputation: 3
I am transforming a sales order to an invoice record in SuiteScript 2.1
let soIID = 1 //just for the sake of the question, this will come from getInputData on a M/R
let invoiceRecord = record.transform({
fromType: 'salesorder',
fromId: soIID,
toType: 'invoice',
});
invoiceRecord.setValue('trandate', new Date(soDate.trandate));
invoiceRecord.save();
let invoiceId = invoiceRecord.getValue('id'); //Problem here
let invoiceId2 = invoiceRecord.getValue({fieldId: 'id'}); //Problem here
My issue is that I cannot retrieve the invoiceId from the transformed record even after a .save() event. I know that both invoiceId and invoiceId2 would work if I first did a record.load() but I still have the problem of not knowing the ID of the invoice record.
When I log the invoiceRecord object the ID isn't included.
How do I retrieve the ID from the newly created object?
Upvotes: 0
Views: 710
Reputation: 609
Record.save()
returns the internal ID of the record that was created so you don't have to retrieve it using getValue
.
const invoiceId = invoiceRecord.save();
Upvotes: 1