/\*\*
* @NApiVersion 2.x
* @NScriptType UserEventScript
\*/
define(\['N/log', 'N/record'\],
function(log, record) {
function beforeSubmit(context) {
try {
// Get the new record from the context
var newRecord = context.newRecord;
// Check if the 'consoldaysoverdue' field has changed
if (context.type === context.UserEventType.EDIT && newRecord.isFieldChanged({
fieldId: 'consoldaysoverdue'
})) {
// Hide popup notifications for the 'consoldaysoverdue' field
newRecord.setField({
fieldId: 'suppressFieldRecalculation',
value: true
});
}
} catch (e) {
// Log any errors
log.error({
title: 'Error Hiding Popup Notification',
details: e.toString(),
});
}
}
return {
beforeSubmit: beforeSubmit,
};
}
);
I've tried changing the script type to Client Script. And I get another error message that it must be a UserEvent Type. The function of this code is to eliminate the "Consolidated days due" pop up notification that keeps appearing on customer forms.
Regarding your error you likely have to delete the script before you can upload a file with a changed script type. i.e. If you first uploaded your file with
and then defined a script you'd have to delete the script in order to change the script type defined in the file.
However given what you are trying to do a
ClientScriptis the way to go.