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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error: Unable to get property 'setVisible' of undefined null reference

(0) ShareShare
ReportReport
Posted on by

Hi All,

Thank you in advance for your help on this.  I have been combing through the forums and found several answers related to my situation but they weren't helpful.   Below is the code in question and I don't see why this error should be coming up.   I am using CRM 2013 Online and while I changed and deleted a couple of fields, as well as re-purpose an existing sub-grid, I did not change the name of any of the tabs?

function onLoad()
{
if (Xrm.Page.getAttribute("customertypecode").getValue() != null)
{
switch (Xrm.Page.getAttribute("customertypecode").getText())
{
case "Agent":
hideTab("Agent",true);
hideTab("Producer",false);
break;
case "Producer":
hideTab("Agent",false);
hideTab("Producer",true);
break;
case "Dealer":
hideTab("Agent",false);
hideTab("Producer",true);
break;
default:
hideTab("Agent",false);
hideTab("Producer",false);
break;
}
}
}

function hideTab (tabName, visible)
{
Xrm.Page.ui.tabs.get(tabName).setVisible(visible);
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Royal King Profile Picture
    27,686 on at

    check whether tab exists or not before setting the visibility

    Something like below should work

    function hideTab (tabName, visible)

    {

    if(Xrm.Page.ui.tabs.get(tabName) != null && Xrm.Page.ui.tabs.get(tabName) != 'undefined')

    Xrm.Page.ui.tabs.get(tabName).setVisible(visible);

    }

  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi David,

    To hide tab, you need to use tab Name

    tab.PNG

    also, javascript is case sensitive, so if your tab name is  agent and you specified Agent, then also it will throw error. 

    One more thing always check for object before changing property.. 

    function hideTab (tabName, visible) 
    {

    var tab = Xrm.Page.ui.tabs.get(TabName);

    if(tab ! =null)

     {
         tab.setVisible(visible);

    }
    }

    Hope this will help.. 

  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you so much Chitra, I tried your code first to see if that would work and it did!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans