I am trying to use JavaScript, which is definately not my expertisie, to hide/show a tab on a form based on the form type of record.
If form type is 1 (create) I want to hide the summary tab. If the form type is 2 (update), I want to show the summary tab.
I have Googled me to the code below, which I use on load of the form - and that works to some extent.
//Hide Summary tab on Create form
function HideSummaryTab(executionContext) {
//Get form context
var formContext = executionContext.getFormContext();
//Get form type
var formType = formContext.ui.getFormType();
//If formtype is Create, hide Summary tab on form
if (formType == 1) {
formContext.ui.tabs.get("summary").setVisible(false);
}
//To see the form type return value in your browser console
console.log("Form type = " formType);
}
However:
1. Is there any way to avoid the delay there is when the form is loaded? First it loads the form - then it hides the tab. Not the best user experience.
2. What is the best way to show the tab after save? Do I need to modify the code above, and add an on save event?