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 :
Microsoft Dynamics CRM (Archived)

Show/Hide Tab with Java Script

(0) ShareShare
ReportReport
Posted on by 70

Hi,

I've been trying to write some Java Script to show/hide a tab within the opportunity form using information online and reviewing other posts within the forum. On our form is a tick box field called 'TV' (wi_tv). When the field is ticked I would like the form to display a subgrid tab called 'TV Revenue' and when unticked the tab should not be visible. I've removed the 'Visible by default' tick from the TV Revenue tab and tried applying the below script, however when the form loads I get an error saying 'Object doesn't support property of method 'getvalue''.

function HideTVRevenueTabOnLoad() {  
    if(Xrm.Page.getAttribute("wi_tv").getvalue() ==1)
{
Xrm.Page.ui.tabs.get("TV Revenue").setVisible(true);
}
else {
Xrm.Page.ui.tabs.get("TV Revenue").setVisible(false);
   }
}

I'm a complete novice with Java Script so no doubt I've made a rookie mistake somewhere in the script but having made several tweaks and changes to it I'm unsure where I'm going wrong. Any advice would be greatly appreciated.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Show/Hide Tab with Java Script

    hi,

    use this code

    function HideTVRevenueTabOnLoad()

    {  

    var a = Xrm.Page.getAttribute("wi_tv").getvalue();

       if(a==1)

    {

    Xrm.Page.ui.tabs.get("TV Revenue").setVisible(true);

    }

    else

    {

    Xrm.Page.ui.tabs.get("TV Revenue").setVisible(false);

      }

    }

    use this code on change of check box

    Regards,

    Nithin

  • Verified answer
    Wouter Madou Profile Picture
    3,392 on at
    RE: Show/Hide Tab with Java Script

    Make sure you got the != null as well.

    Checkbox is default null instead of 0

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Show/Hide Tab with Java Script

    please use schema name of tab

    function hideshow(){

    var a1 = Xrm.Page.getAttribute("new_typeofclaim").getValue();

    if(a1 != null){

    if(a1 == 100000000){

    Xrm.Page.ui.tabs.get("tab1").setVisible(true);

    }

    else{

    Xrm.Page.ui.tabs.get("tab1").setVisible(false);

    }

    }else

    {

    Xrm.Page.ui.tabs.get("tab1").setVisible(false);

    }

    }

    Regards,

    Nithin

  • Verified answer
    Jeroen Pasman Profile Picture
    on at
    RE: Show/Hide Tab with Java Script

    Javascript functions are case sensitive and I see you are calling getvalue(), this should be getValue()

  • Neil Renwick Profile Picture
    70 on at
    RE: Show/Hide Tab with Java Script

    Thanks for the info Wouter

  • Neil Renwick Profile Picture
    70 on at
    RE: Show/Hide Tab with Java Script

    Thanks so much Nithin, code is working perfectly

  • Neil Renwick Profile Picture
    70 on at
    RE: Show/Hide Tab with Java Script

    Good to know Jeroen, will watch out for this in future

  • Suggested answer
    Saddamk206 Profile Picture
    777 on at
    RE: Show/Hide Tab with Java Script

    it is not possible by Business Rules. You can use javascript for hide and show

    //Hide the tab

    Xrm.Page.ui.tabs.get("TabName").setVisible(false);

    //Show the tab

    Xrm.Page.ui.tabs.get("TabName").setVisible(true);

  • Sagar Ingale Profile Picture
    10 on at
    RE: Show/Hide Tab with Java Script

    You can use the below function. Make sure there is NO " " (space) while giving tab name.

    function functionName()

    {

    var Value= Xrm.Page.getAttribute('TwoOptionSetSchemaName').getText();

    if(Value=="Yes")

    {

    Xrm.Page.ui.tabs.get("tab_17").setVisible(true);

    }

    else

    {

    Xrm.Page.ui.tabs.get("tab_17").setVisible(false);

    }

    }

  • CBMavic Profile Picture
    30 on at
    RE: Show/Hide Tab with Java Script

    I like this idea, just not sure how you would add this method, since there is no tab functionality in business rules

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans