This topic contains 7 replies, has 0 voices, and was last updated by chanarbon 8 years ago.
-
AuthorPosts
-
October 7, 2016 at 1:49 am #1731
mvk4a092How to get Current Record type and internal id dynamically in UserEvent AfterSubmit in SuiteScript 2.0 ? In SuiteScript 1.0 nlapiGetRecordType() and nlapiGetRecordId() what in SuiteScript 2.0 will replace those two apis?
Please Help!
This is a cached copy. Click here to see the original post. -
October 7, 2016 at 3:18 am #1732
david.smithscriptContext.currentRecord.type and scriptContext.currentRecord.id
-
October 7, 2016 at 6:49 am #1733
JacksonPThey also added a currentRecord module!
https://system.netsuite.com/app/help…625600928.html
-
October 10, 2016 at 5:26 am #1734
Olivier Gagnon NCNote that currentRecord on aftersubmit is buggy and does not return correct values. You must load the record just saved as a workaround.
-
October 27, 2016 at 6:27 am #1735
mvk4a092My Code is
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define([‘N/record’],
function(record,currentRecord) {
function afterSubmit(scriptContext) {
log.debug(‘script Triggered’,’User Event’);
var recordId=scriptContext.currentRecord.id;
log.debug(‘recordId’,recordId);
var objRecord = record.load({type: record.Type.SALES_ORDER,id: recordId,isDynamic: true,});
log.debug(‘objRecord’,objRecord);
}
return {
afterSubmit: afterSubmit
};
});
Error is: org.mozilla.javascript.EcmaError: TypeError: Cannot read property “id” from undefined (/SuiteScripts/User Event 2.0.js#9)
โHelp Me….
-
October 27, 2016 at 8:04 am #1736
JacksonPI noticed that you’re not loading the ‘N/currentRecord’ module in the define statement, but passing a variable for currentRecord.
-
October 27, 2016 at 9:06 am #1737
Olivier Gagnon NCSee corrections below. Give this a shot.
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define([‘N/record’],
function(record) {
function afterSubmit(scriptContext) {
log.debug({title:’script Triggered’,details:’User Event’});
var recordId=scriptContext.newRecord.id;
log.debug({title:’recordId’,details:recordId});
var objRecord = record.load({type: record.Type.SALES_ORDER,id: recordId,isDynamic: true,});
log.debug({title:’objRecord’,details: objRecord});
}
return {
afterSubmit: afterSubmit
};
});
-
October 27, 2016 at 7:34 pm #1738
chanarbonHi @mvk4a092,
Please note that for the afterSubmit entry point, it does not have a context.currentRecord. User Event Scripts contain context.oldRecord and context.newRecord except beforeLoad which only has context.newRecord that’s why you should use context.newRecord for this concern.
-
AuthorPosts
You must be logged in to reply to this topic.