JC
01/03/2025, 3:40 PM/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/ui/serverWidget', 'N/log'], (serverWidget, log) => {
function beforeLoad(context) {
if (context.type === context.UserEventType.CREATE) {
hideColumnField(context.form, 'item', 'taxcode');
}
}
function hideColumnField(formObj, item, taxcode) {
try {
const formSublist = formObj.getSublist({
id: 'item'
});
if (formSublist) {
const formField = formSublist.getField({
id: 'taxcode'
});
if (formField && typeof formField !== 'undefined' && formField !== null) {
formField.updateDisplayType({
displayType: serverWidget.FieldDisplayType.HIDDEN
});
}
}
} catch(error) {
log.error({
title: 'Error:',
details: JSON.stringify({
item: item,
taxcode: taxcode
})
});
}
}
return {
beforeLoad: beforeLoad
};
});
alien4u
01/03/2025, 4:17 PMerictgrubaugh
01/03/2025, 4:26 PMerictgrubaugh
01/03/2025, 4:29 PMhideColumnField
function can be reduced to
function hideColumnField(form) {
form?.getSublist({ id: 'item' })?.getField({ id: 'taxcode' })?.updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN })
}
Less code - specifically, fewer branching if
statements - should be a little easier to troubleshootAnthony OConnor
01/03/2025, 5:59 PMJC
01/04/2025, 8:41 PMJC
01/04/2025, 8:54 PMJC
01/04/2025, 8:54 PMAnthony OConnor
01/04/2025, 9:09 PMJC
01/04/2025, 9:57 PM