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)

Help with script to hide tab based on two option field

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to use following code:

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


  • Charles Abi Khirs Profile Picture
    3,569 on at

    Hello,

    What is the error you have?

  • Community Member Profile Picture
    on at

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

  • Suggested answer
    Somira Profile Picture
    5 on at

    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);

    }

    }

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