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)

Hiding tabs using 'if' statements in java

(0) ShareShare
ReportReport
Posted on by 25

Hi,

I have been trying to get our CRM to show/hide tabs on a form based on the sale type that it relates to. We have an orders page that contains all relevant info for a sale, currently all fields for all possible sale types are displayed on the form I.E. Gas, Electricity, Telecoms etc. Based on a look up field at the top of the form I want to show the relevant tabs for the sale type. So far I have managed to get the system to get the system to hide tabs if they are not relevant for a sale but this results in the unwanted tabs showing for a few seconds while the system works through the script, a smarter way to do this would be to hide the tabs by default and then get the system to show the tab that corresponds to the sale type. I thought this would be as simple as reversing the code but it does not seem to work, whatever I try, the Electricity tab still shows up for all sale types. Please see below code and advise of any issues you can find... Thanks.

function showhidetab() {

//Get producttype
       
        var producttype = new Array();
        var producttype = Xrm.Page.getAttribute("new_producttype").getValue();      
       
//If product type equals electric then show electricity tab

        if (producttype = 100000001) {
        Xrm.Page.ui.tabs.get("Electricity Contract Information").setVisible(true);
}
        else {
        Xrm.Page.ui.tabs.get("Electricity Contract Information").setVisible(false);

}
      
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    Use == instead of = in the if clause. == is comparing the values while = is setting the value.

    Regards,

    Marc

  • Matt Bird Profile Picture
    25 on at

    Great stuff, that's fixed it... I'm new to all this Java script stuff, just working it out as I am going along to be honest, but I will bare this one in mind for future... Thanks for your help!

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