Mike Robbins
07/28/2021, 3:36 PMoldRecord
and newRecord
to look for differences.
context.oldRecord
is being passed to getRecordData()
function but for some reason its value is null
so I’m getting “TypeError: Cannot read property ‘getValue’ of null”. This workflow is not set to run on “Create”, only “View and Update”, so oldRecord
should always exist.
Any idea why this would happen? This script works as expected in our sandbox but it has not worked in production.
/**
* @NApiVersion 2.1
* @NScriptType WorkflowActionScript
* @NModuleScope Public
*/
define(['N/log', './lodash'], function (log, _) {
function onAction(context) {
const oldRecord = getRecordData(context.oldRecord);
const newRecord = getRecordData(context.newRecord);
return _.isEqual(oldRecord, newRecord) ? 'F' : 'T';
}
function getRecordData(record) {
const recordData = {
lines: []
};
// 'record' is null here
recordData.entity = record.getValue({ fieldId: 'entity' });
recordData.usertotal = record.getValue({ fieldId: 'usertotal' });
// Do some more stuff here
return recordData;
}
return {
onAction
};
});
Sandii
07/28/2021, 4:46 PMMike Robbins
07/28/2021, 6:23 PMSandii
07/28/2021, 6:40 PMonAction: onAction
Bibek Shrestha
07/28/2021, 6:53 PM