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?

Rookie Asked on January 24, 2024 in SuiteScript.
Add Comment
5 Answer(s)

Po doesn’t have expense subtab

Rookie Answered on January 25, 2024.
Add Comment

I am referring to suite answers 75284.    I cant get the 2.0 code example to work.

Rookie Answered on January 25, 2024.
Add Comment

Thanks, that worked.

 

Rookie Answered on January 25, 2024.
Add Comment

It hides it when in the create and edit mode.  But doesn’t in the view mode.

Rookie Answered on January 25, 2024.
Add Comment

 

/**
* @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.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor