Tim Chapman
12/27/2023, 5:57 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record', 'N/runtime'], function(record, runtime) {
function afterSubmit(context) {
var newRecord = context.newRecord;
var approvalStatus = newRecord.getValue({fieldId: 'approvalstatus'});
if (approvalStatus === '2') {
var currentDate = new Date();
// Update the custom field with the current date
record.submitFields({
type: newRecord.type,
id: newRecord.id,
values: {
custbody34: currentDate
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
}
}
return {
afterSubmit: afterSubmit
};
});
Israel Gonzalez
12/27/2023, 6:15 PMTim Chapman
12/27/2023, 6:26 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record', 'N/runtime'], function(record, runtime) {
function afterSubmit(context) {
var newRecord = context.newRecord;
// Get the current value of 'custbody34'
var custbody34 = newRecord.getValue({fieldId: 'custbody34'});
// Check if 'custbody34' is null or empty
if (!custbody34) {
var status = newRecord.getValue({fieldId: 'status'});
if (status === '2') {
var currentDate = new Date();
// Update the custom field with the current date
record.submitFields({
type: newRecord.type,
id: newRecord.id,
values: {
custbody34: currentDate
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
}
}
}
return {
afterSubmit: afterSubmit
};
});
Tim Chapman
12/27/2023, 6:26 PMTim Chapman
12/27/2023, 6:31 PM