Hello,
I've been receiving the following error in my code once I've injected it onto my form - formContext.ui.tabs.get(...).setDisabled is not a function
Here is my code:
function HideAndDisableTabsBasedOnBPFStage(executionContext) { var formContext = executionContext.getFormContext(); // Hide and disable tabs based on the current BPF stage var bpfStageId = formContext.data.process.getActiveStage().getId(); switch (bpfStageId) { case "abbda151-be8f-462a-99b9-b32231baadaf": // Hide and disable tabs for Request stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(false); formContext.ui.tabs.get("tab_JBSIS").setVisible(false); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "ea3aa60c-f952-4edb-b955-c78c2cebc3a6": // Hide and disable tabs for Court Approver stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(false); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "0d92ffa6-786d-4e4b-b790-695f4495c7a7": // Hide and disable tabs for Court Approver (non-charging) stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(false); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "bdcfd44f-6b69-47ef-9785-a7a3c029169c": // Hide and disable tabs for JBSIS stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_Requestor").setDisabled(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setDisabled(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(true); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "bccdfa2d-831a-4f4e-a370-c0d3b130914b": // Hide and disable tabs for Finance stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_Requestor").setDisabled(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setDisabled(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(false); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(true); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "fcfaceed-fc37-4dde-9351-f8942fe2b73f": // Hide and disable tabs for CTS Review stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_Requestor").setDisabled(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setDisabled(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(false); formContext.ui.tabs.get("tab_CTS").setVisible(true); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break; case "f712096e-f750-4b6e-a10e-0e8d3184387e": // Hide and disable tabs for CTS Entry stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_Requestor").setDisabled(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").setDisabled(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(true); formContext.ui.tabs.get("tab_JBSIS").setDisabled(true); formContext.ui.tabs.get("tab_CTS").setVisible(true); formContext.ui.tabs.get("tab_CTS").setDisabled(true); formContext.ui.tabs.get("tab_Finance").setVisible(true); formContext.ui.tabs.get("tab_Finance").setDisabled(true); formContext.ui.tabs.get("tab_CTSEntry").setVisible(true); break; default: break; } } // Add event handlers for OnLoad and OnStageChange events Xrm.Page.data.process.addOnLoad(HideAndDisableTabsBasedOnBPFStage); Xrm.Page.data.process.addOnStageChange(HideAndDisableTabsBasedOnBPFStage);
I'd also like to note that if I delete all the setDisabled code and leave the setVisible code, the script executes perfectly. Not sure why it is not working for setDisabled even though I see a lot of documentation online where the code is the same in my script above.
Hi AK91,Not sure what is it you are trying to do. you can't disable a section/tab - there is no setDisabled() method:learn.microsoft.com/.../formcontext-ui-tabs
Thanks,Manoj Mane.Please mark this as VERIFIED if it helps.
Hi Manoj Mane ,
As my business process flow progresses to different stages, I would like to hide/disable other tabs on my form. So, for instance, when my BPF reaches the 'JBSIS' stage, I want to display the Requestor and Court Approver tabs but not allow the users to edit the information within them.
case "bdcfd44f-6b69-47ef-9785-a7a3c029169c": // Hide and disable tabs for JBSIS stage formContext.ui.tabs.get("tab_Requestor").setVisible(true); formContext.ui.tabs.get("tab_Requestor").sections.get("General").setDisabled(true); formContext.ui.tabs.get("tab_Requestor").sections.get("RequestorInformation").setDisabled(true); formContext.ui.tabs.get("tab_Requestor").sections.get("RequestInformation").setDisabled(true); formContext.ui.tabs.get("tab_Requestor").sections.get("OffenseInformation").setDisabled(true); formContext.ui.tabs.get("tab_Requestor").sections.get("AdditionalOffenseInformation").setDisabled(true); formContext.ui.tabs.get("tab_CourtApprover").setVisible(true); formContext.ui.tabs.get("tab_CourtApprover").sections.get("CourtApprover").setDisabled(true); formContext.ui.tabs.get("tab_JBSIS").setVisible(true); formContext.ui.tabs.get("tab_CTS").setVisible(false); formContext.ui.tabs.get("tab_Finance").setVisible(false); formContext.ui.tabs.get("tab_CTSEntry").setVisible(false); break;
I've tried this code to try disabling the sections within a tab and received the error: formContext.ui.tabs.get(...).sections.get(...).setDisabled is not a function
export function getFormContext(parent?: Window): Xrm.FormContext { //debugger; let context: Xrm.FormContext; if (formContext) { context = formContext; } return context; } //Hide a tab export function hideTab(tabName: string): void { var tab = getFormContext().ui.tabs.get(tabName); if (tab != null) { tab.setVisible(false); } } //show a tab export function showTab(tabName: string): void { var tab = getFormContext().ui.tabs.get(tabName); if (tab != null) { tab.setVisible(true); } }
The only thing that comes to mind why it wouldn't work is I remember when we went from V8 to V9 we had to swap all the 1/0 to true/false but that doesn't seem to be the case
As I was working with the issue, I realized that setVisible can be applied to tabs, however, setDisable can only be applied to individual controls. I was able to modify my code to fit this although it was a bit tedious.
Hi AK91,Yes we can not apply setDisabled() method to the tab/section. You can hide the tabs based on your current selected tab.Thanks,Manoj Mane.Please mark this as VERIFIED if it helps.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 228
Tom_Gioielli 156 Super User 2025 Season 2
MVP-Daniyal Khaleel 149