Hi Guys,
I need help please :)
I have done some JavaScript to hide sections based on field "option set" value.
Everything works fine, however when I save & close the record and reopen it, all sections become visible again.
Please see script below:
function ViewFormSection() {
debugger;
var riskType = Xrm.Page.getAttribute("new_risktype").getValue();
var sections = Xrm.Page.ui.tabs.get("RiskDetails").sections;
var visibilityByRiskType = {
"2": // Commercial Combined
{
"HKQ" : false,
"MCD" : false,
"CI" : false,
"BVW" : false,
},
"3": {//Computers
"HKQ" : false,
"MCD" : false,
"CI" : false,
"BVW" : false,
},
"4": { //Contract Works
"HKQ" : true,
"MCD" : true,
"CI" : true,
"BVW" : true,
},
// ALL
"1": {
"HKQ" : false,
"MCD" : true,
"CI" : true,
"BVW" : true,
}
};
for (var i in visibilityByRiskType[riskType]) {
if(typeof sections.get(i) == 'undefined' || sections.get(i) == null){
alert(i + ' section is undefined');
}
sections.get(i).setVisible(visibilityByRiskType[riskType][i]);
}
}
*This post is locked for comments