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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer Service forum

JavaScript for hiding sections using the Title from the Subject field (Case Management)

(0) ShareShare
ReportReport
Posted on by

Dear Community,

I'm trying to hide/show sections based on the selection made on the "subject" of a case. I understand that the subject is in fact the subject ID but what I need to do is find out the "title" from this so that I can show/hide a section.

My script as it stands is below however this produces an error:

function showHide() {

if (Xrm.Page.data.entity.attributes.get("subjectid").getValue() != null) {

           var Title= Xrm.Page.data.entity.attributes.get("subjectid").getValue()[0].name;
       }


 {
 if (Title = "A")


 {
 Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(true);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(false);


}
 else if (Title = "B")
 {
 Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(true);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(false);
 }

 else if (Title = "C")
 {
 Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(true);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(false);
 }

 else if (Title = "D")
 {
 Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(true);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(false);
 }

 else if (Title = "E")
 {
  Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(true);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(false);
 }

 else if (Title  = "F")
 {
 Xrm.Page.ui.tabs.get("general").section.get("A").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("B").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("C").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("D").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("E").setVisible(false);
 Xrm.Page.ui.tabs.get("general").section.get("F").setVisible(true);
 }

}
}

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

    Hello,

    In your if statements use == instead on = like:

    else if (Title == "B")

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans