web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

(0) ShareShare
ReportReport
Posted on by 5

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);
Thanks in advance!
I have the same question (0)
  • AK91 Profile Picture
    5 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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.

  • Suggested answer
    Manoj Mane Profile Picture
    1,020 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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. image

  • AK91 Profile Picture
    5 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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.

  • AK91 Profile Picture
    5 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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

  • Christopher Klein Profile Picture
    20 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.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

  • AK91 Profile Picture
    5 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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.

  • Suggested answer
    Manoj Mane Profile Picture
    1,020 on at
    RE: Has setDisabled been deprecated? I'm getting this error - formContext.ui.tabs.get(...).setDisabled is not a function

    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. image

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 228

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 156 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 149

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans