Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Help with script to hide tab based on two option field

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm pulling my hair out trying to get this figured out. I'm trying to write what I believe is a very simple script, but I've literally been working on this for days and can't figure it out.  Every code I write gives me an error. Every correction I make gives me an error. Error after error after error. 

Can someone PLEASE help me? And use small words, because I don't understand what I'm doing. 

I have a two option field and a tab. I'm trying to show the tab if a two option field is ticked Yes, else hide it. If it says No or is Blank, the tab should be hidden, if it says Yes it should be visible. I've written several different versions of this code based on info I've found online. This is the 18289357th version of code I've written trying to accomplish this.

What am I doing wrong?

function ShowTab(){

   if(Xrm.Page.getAttribute("new_SRMPlan").getValue() == "1") {

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

   }

   else

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

 

   }

}

*This post is locked for comments

  • Suggested answer
    Somira Profile Picture
    Somira 5 on at
    RE: Help with script to hide tab based on two option field

    Hi

    Good afternoon

    Use following code in onload form :

    function showhidetab()

    {

    var r=Xrm.Page.getAttribute("new_managerconfirm").getValue();

        Xrm.Page.ui.tabs.get("tab_7").setVisible(! r);

    }

    function hideshow(){

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

    if(a1 != null){

    if(a1 == 1){

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

    }

    else{

    Xrm.Page.ui.tabs.get("tab_7").setVisible(ture);

    }

    }else

    {

    Xrm.Page.ui.tabs.get("tab_7").setVisible(ture);

    }

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Help with script to hide tab based on two option field

    Thank you so much! My hero! It works perfectly.

  • Charles Abi Khirs Profile Picture
    Charles Abi Khirs 3,569 on at
    RE: Help with script to hide tab based on two option field

    Hello,

    What is the error you have?

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Help with script to hide tab based on two option field

    Hello,

    Try to use following code:

    function ShowTab(){
    	Xrm.Page.ui.tabs.get("tab_5").setVisible(!!Xrm.Page.getAttribute("new_srmplan").getValue());
    }


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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans