Stoetech


How to Show/Hide Tabs

Tabs function as form controllers within Dynamics 365. With the use of JavaScript, you can implement logic to Show or Hide these controls. Below is a snippet of sample code that can be easily ‘fixed’ to work for your use case.

To manipulate tabs, you must identify the specific tab’s unique name for the show/hide action. To locate tab names: In the Form editor, identifying tab names is straightforward. Simply choose the tab elements within the modern Form editor and look for the “Name” field.

				
					 function tabvisibility(executionContext) {
    let formContext = executionContext.getFormContext();

    if(formContext.getAttribute("FIELDNAME").getValue() == null) {
       formContext.ui.tabs.get("TABNAME").setVisible(true);
                                                                    }
    else {
       formContext.ui.tabs.get("TABNAME").setVisible(false);
            }
}
				
			

If you would like to continue learning about how to use JavaScript, we have an educational blog with many more snippets of code.