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?

jparke Rookie Asked on January 24, 2024 in SuiteScript.
Add Comment
5 Answers

 

/**
* @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
};
});

 

Rookie Answered on January 26, 2024.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.