Thursday, May 9, 2019

Get Transaction ID when creating a record

As Transaction ID (tranid) is generated after the record is saved it is null or has "To Be Generated" value before record is submitted. If the Transaction ID (tranid) is called in User Event Script - After Submit function using nlapiGetFieldValue('tranid') the ID is still not generated yet. Newly generated Transaction ID can be retrieved using nlapiLoadRecord() function.

Example:
function userEventAfterSubmit(type){    var tranid = nlapiGetFieldValue('tranid');    // tranid is null or "To Be Generated" here    nlapiLogExecution('DEBUG', 'tranid  ', tranid);    var RecordId = nlapiGetRecordId();    var salesOrder = nlapiLoadRecord('salesorder',RecordId);    // tranid is generated number (Sales Order #, Inovoice # etc.)    var tranid = salesOrder.getFieldValue('tranid')    nlapiLogExecution('DEBUG', 'tranid from load record ', tranid);}

No comments:

Post a Comment