The issue here is due to two main problems:
1. Incorrect Method Name: getvalue() should be getValue().
2. Incorrect Parameter Type in setVisible(): The setVisible() method expects a boolean parameter (true or false) rather than a string.
Here’s the corrected code:
function TabHideOnLoadOnChange(executionContext) {
var formContext = executionContext.getFormContext();
var WorkOrderStatus = formContext.getAttribute("sog_parentstatus").getValue();
var TabName = formContext.ui.tabs.get("Survey_tab");
var complete = 922830005;
var invoiced = 922830006;
if (WorkOrderStatus == complete || WorkOrderStatus == invoiced) {
TabName.setVisible(true);
} else {
TabName.setVisible(false);
}
}
Explanation of the Changes
getValue(): Use getValue() instead of getvalue() to retrieve the value.
setVisible(true/false): Pass true or false directly (no quotes), as setVisible() expects a boolean value.
This should resolve the error you’re facing and allow the tab visibility to work based on the WorkOrderStatus.