D365 Finance & Operations and Dynamics AX Forum

Null value when trying to hide tabs

  • 1.  Null value when trying to hide tabs

    Posted Dec 01, 2020 12:07 PM
    Edited by Nic Moenssen Dec 01, 2020 04:11 PM
    Hello,

    When trying to hide or show a tab I keep getting a "TypeError: Cannot read property 'setVisible' of null".  I understand why I'm getting this error because CRM can't find the tab name but I'm not sure how to correct it since I know the tab and tab name exist.

    The tab is shown below:
    Screenshot of tab name

    I created the following sample code to try and do a simple test but I still can't get that to work.

    function onSystemRequestFormLoad(executionContext)
    {
        hideTabTest(executionContext);
    }

    function hideTabTest(executionContext)
    {
        formContext = executionContext.getFormContext();    // get formContext

        var tab_Job = formContext.ui.tabs.get("tab_jobstatuschange");   // get tab name
        // test output
        console.log("job tab = " + tab_Job);
        // hide tab
        tab_Job.setVisible(false);
    }

    Any thoughts as to what I'm doing wrong?  According to the MS Documentation it looks like I'm doing everything correct.  Am I calling the arg wrong?

    ----EDIT----
    Was able to figure out my issue.  I renamed the tab on the form but I never did a full Publish All.  So the tab was still showing the default value instead of what I called it.  Apologies for my stupid mistake :/


If you've found this thread useful, dive deeper into User Group community content by role