Hello. My Javascript code works perfectly OnLoad trigger but Only two of the conditions will be successfully satisfied OnChange of a field, leaving out one condition which is to hide a Quick View section and its field. Here is the code:
function CaseType_OnChange()
{
//Get OptionSet CaseType
var caseType = Xrm.Page.getAttribute("casetypecode");
if (caseType == null)
{
return;
}
//Show or Hide Tab and Sections, if CaseType is Claim
if (caseType.getValue() == 1)
{
ShowOrHideTab("tab_1", true);
ShowOrHideSection("section_1", true);
ShowOrHideSection("section_2", true);
}
else
{
ShowOrHideTab("tab_1", false);
ShowOrHideSection("section_1", false);
ShowOrHideSection("section_1", false);
}
}
function ShowOrHideTab(tabName, tabVisibility)
{
//Get Tab
var tab = Xrm.Page.ui.tabs.get(tabName);
//Set Visibility if tab was found
if (tab != null)
{
tab.setVisible(tabVisibility);
}
}
function ShowOrHideSection(sectionName, sectionVisibility)
{
//Get Tab
var section = Xrm.Page.ui.tabs.get("general").sections.get(sectionName);
//Set Visibility if section was found
if (section != null)
{
section.setVisible(sectionVisibility);
}
}
SO, on that ShowOrHideSection("section_1",false), the section of which it is a Quick View form, it is not getting hidden OnChange of the CaseType field.
What could be the problem?
Best Regards
Junior Consultant