Nicolas Bean
04/11/2022, 2:57 PMSciuridae54696d
04/11/2022, 3:00 PMNicolas Bean
04/11/2022, 3:01 PMSciuridae54696d
04/11/2022, 3:03 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope Public
*
*/
define(['N/record','N/runtime'], function(record,runtime) {
/**
* @function afterSubmit
* @description description
*
* @public
* @param {type} context.newRecord
* @param {type} context.oldRecord
* @param {type} context.type
*/
function checkIsDynamic(context){
log.debug({title:"isDynamic",details:context.newRecord.isDynamic});
}
function afterSubmit(context) {
try{
var startTime = new Date().getTime();
checkIsDynamic(context);
} catch (e) {
var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
var scriptId = runtime.getCurrentScript().id;
var endTime = new Date().getTime();
log.error("fn:afterSubmit:Error: "+ context.newRecord.type +":"+context.newRecord.id, JSON.stringify(e));
}
var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
log.debug('afterSubmit', 'remainingUsage: ' + remainingUsage);
return true;
}
/**
* @function beforeLoad
* @description description
*
* @public
* @param {type} context.newRecord
* @param {type} context.type
* @param {type} context.form
* @param {type} context.request
* @return {type} - description
*/
function beforeLoad(context) {
try{
checkIsDynamic(context);
} catch (e) {
var scriptId = runtime.getCurrentScript().id;
log.error('ERROR:'+scriptId+':fn.beforeLoad:'+runtime.executionContext, JSON.stringify(e));
}
var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
log.debug('beforeLoad', 'remainingUsage: ' + remainingUsage);
return true;
}
/**
* @function beforeSubmit
* @description description
*
* @public
* @param {type} context.newRecord
* @param {type} context.oldRecord
* @param {type} context.type
*/
function beforeSubmit(context) {
try{
checkIsDynamic(context);
} catch (e) {
var scriptId = runtime.getCurrentScript().id;
log.error('ERROR:'+scriptId+':fn.beforeSubmit:'+runtime.executionContext, JSON.stringify(e));
}
var remainingUsage = runtime.getCurrentScript().getRemainingUsage();
log.debug('beforeSubmit', 'remainingUsage: ' + remainingUsage);
return true;
}
return {
afterSubmit:afterSubmit,
beforeLoad:beforeLoad,
beforeSubmit:beforeSubmit
};
});
Nicolas Bean
04/11/2022, 3:21 PM