RE: Does anyone have a script to hide the expense subtab on a purchase order in Suite Script 2.0?
Does anyone have a script to hide the expense subtab on a purchase order in Suite Script 2.0?
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/search', 'N/ui/serverWidget'], function(search, serverWidget) {
function beforeLoad(context) {
var type = context.type;
var expenseFormId = getExpenseFormId(context, type);
if (expenseFormId === '146') {
hideExpenseSublist(context.form);
}
}
function getExpenseFormId(context, type) {
if (type === context.UserEventType.VIEW) {
return search.lookupFields({
type: context.newRecord.type,
id: context.newRecord.id,
columns: ['customform']
}).customform[0].value;
} else {
return context.newRecord.getValue({fieldId: 'customform'});
}
}
function hideExpenseSublist(form) {
var expenseSublist = form.getSublist({id: 'expense'});
expenseSublist.displayType = serverWidget.SublistDisplayType.HIDDEN;
}
return {
beforeLoad: beforeLoad
};
});