Skip to main content

Notifications

Announcements

No record found.

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!
  • Suggested answer
    Manoj Mane Profile Picture
    1,012 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

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

  • 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

    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

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

  • Suggested answer
    Manoj Mane Profile Picture
    1,012 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

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,002 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans