Sim Greenbaum
10/29/2020, 2:46 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record'],
/**
* @param {record} record
*/
function (record) {
function afterSubmit(scriptContext) {
//Step 1
rec = scriptContext.oldRecord;
//Step 2
var extId = rec.getValue({ fieldId: 'externalid' });
var amazonsku = rec.getValue({ fieldId: 'custitem3' });
//Step 3
if (amazonsku != extId) {
//Step 4
record.submitFields({
id: rec.id,
values: {
'externalid': amazonsku
}
});
}
//Step 5
var newext = rec.getValue({ fieldId: 'externalid' });
log.debug('rec id', rec.id)
}
return {
afterSubmit: afterSubmit
};
});
Sandii
10/29/2020, 2:49 PMSim Greenbaum
10/29/2020, 2:49 PMSim Greenbaum
10/29/2020, 2:50 PMbattk
10/29/2020, 2:50 PMSim Greenbaum
10/29/2020, 2:50 PMbattk
10/29/2020, 2:51 PMscottvonduhn
10/29/2020, 2:51 PMSim Greenbaum
10/29/2020, 2:52 PMscottvonduhn
10/29/2020, 2:53 PMSim Greenbaum
10/29/2020, 2:54 PMscottvonduhn
10/29/2020, 2:57 PMrec.type
?Sim Greenbaum
10/29/2020, 2:58 PMbattk
10/29/2020, 2:58 PMSim Greenbaum
10/29/2020, 2:59 PMscottvonduhn
10/29/2020, 2:59 PMSciuridae54696d
10/29/2020, 3:00 PMscriptContext.oldRecord.type
this will give you the record type that battk is talking about - which will make your code dynamic
then you will need to do
record.submitFields({
type:rec.type,
id: rec.id,
values: {
'externalid': amazonsku
}
});
Sim Greenbaum
10/29/2020, 3:00 PMSciuridae54696d
10/29/2020, 3:02 PMSciuridae54696d
10/29/2020, 3:03 PMSim Greenbaum
10/29/2020, 3:43 PMSim Greenbaum
10/29/2020, 3:59 PMbattk
10/29/2020, 4:27 PMSandii
10/30/2020, 3:00 PMoldRecord
so if you are referencing that, could definitely be a problemSim Greenbaum
10/30/2020, 3:31 PMbattk
10/30/2020, 9:29 PMbattk
10/30/2020, 9:30 PMbattk
10/30/2020, 9:31 PMbattk
10/30/2020, 9:32 PMscriptContext.type
battk
10/30/2020, 9:33 PMEvent Type
on the script deploymentbattk
10/30/2020, 9:33 PM