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);
}
}
}
Hello,
In your if statements use == instead on = like:
else if (Title == "B")
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156