Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Hide Multi Choice field based on a drop down value

$
0
0

Since I can't use Business Rule to hide a Multi choice field can I add code to existing javascript function to hide this field (vantage_typeofsupportiveservicesneeded) based on option set (mat_tasktype) value of (809600021)? I am not well versed in JavaScript.

I was trying to figure out how I would set my var SSNeeded to the field vantage_typeofsupportiveservicesneeded)? and then add it to each case value to set visibility true or false.

This is what my current code looks like which hides & shows sections & tabs on the Task form based on the value selected on (mat_tasktype). I am only including 1 case situation below to keep the code smaller on this post. Original code includes case for each option set value.

---------------------------------------------------------

function HideOption() {
var form_type = Xrm.Page.ui.getFormType();

if (form_type == 1) {
var pickListField = Xrm.Page.getControl("mat_tasktype");
pickListField.removeOption(809600004);
pickListField.removeOption(809600007);
}
else {
Xrm.Page.ui.controls.get("mat_tasktype").setDisabled(true);
}
}


function hideshowtasksections() {
setTimeout(hideshowtasksections1, 250);
}
function hideshowtasksections1() {

var tbSec10 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_10"); 
if (tbSec10 != null) { tbSec10.setVisible(false); }

var tbSec9 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_9"); 
if (tbSec9 != null) { tbSec9.setVisible(false); }

var tbSec8 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_8"); 
if (tbSec8 != null) { tbSec8.setVisible(false); }

var tbSec7 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_7"); 
if (tbSec7 != null) { tbSec7.setVisible(false); }
var tbSec6 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_6"); 
if (tbSec6 != null) { tbSec6.setVisible(false); }
var tb2 = Xrm.Page.ui.tabs.get("task").sections.get("task_section_4"); 
if (tb2 != null) { tb2.setVisible(false); }
var tb3 = Xrm.Page.ui.tabs.get("task").sections.get("tab_3"); 
if (tb3 != null) { tb3.setVisible(false); }


var tb7 = Xrm.Page.ui.tabs.get("tab_7"); 
if (tb7 != null) { tb7.setVisible(false); }
var tb8 = Xrm.Page.ui.tabs.get("tab_8"); 
if (tb8 != null) { tb8.setVisible(false); }
var tb9 = Xrm.Page.ui.tabs.get("tab_9"); 
if (tb9 != null) { tb9.setVisible(false); }
var tb10 = Xrm.Page.ui.tabs.get("tab_10"); 
if (tb10 != null) { tb10.setVisible(false); }
var tb11 = Xrm.Page.ui.tabs.get("tab_11");
if (tb11 != null) { tb11.setVisible(false); }
var tb12 = Xrm.Page.ui.tabs.get("tab_12");
if (tb12 != null) { tb12.setVisible(false); }
var tb13 = Xrm.Page.ui.tabs.get("tab_13"); 
if (tb13 != null) { tb13.setVisible(false); }
var tb14 = Xrm.Page.ui.tabs.get("tab_14"); 
if (tb14 != null) { tb14.setVisible(false); }
var tb15 = Xrm.Page.ui.tabs.get("tab_15"); 
if (tb15 != null) { tb15.setVisible(false); }
var tb16 = Xrm.Page.ui.tabs.get("tab_16"); 
if (tb16 != null) { tb16.setVisible(false); }

var attr = Xrm.Page.getAttribute("mat_tasktype")
var val = "";
if (attr != null) {
var attrValue = attr.getValue();
if (attrValue != null) {
switch (parseInt(attrValue)) {

case 809600020: 
tbSec10.setVisible(false);
tbSec9.setVisible(false);
tbSec8.setVisible(false);
tbSec7.setVisible(false);
tbSec6.setVisible(true);
tb2.setVisible(false);
tb3.setVisible(false);
tb7.setVisible(false);
tb8.setVisible(false);
tb9.setVisible(false);
tb10.setVisible(false);
tb11.setVisible(false);
tb12.setVisible(false);
tb13.setVisible(false);
tb14.setVisible(false);
tb15.setVisible(false);
tb16.setVisible(false);
break;

case 809600019: 
tbSec10.setVisible(false);
tbSec9.setVisible(false);
tbSec8.setVisible(false);
tbSec7.setVisible(false);
tbSec6.setVisible(false);
tb2.setVisible(true);
tb3.setVisible(false);
tb7.setVisible(false);
tb8.setVisible(false);
tb9.setVisible(false);
tb10.setVisible(false);
tb11.setVisible(false);
tb12.setVisible(false);
tb13.setVisible(false);
tb14.setVisible(false);
tb15.setVisible(false);
tb16.setVisible(false);
break;
}
}

var form_type2 = Xrm.Page.ui.getFormType();
if (form_type2 == 1) {
var destAttr = Xrm.Page.data.entity.attributes.get("subject");
destAttr.setValue(val);
destAttr.setSubmitMode("always");
}
}


}


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images