The following is a script for Microsoft Dynamics CRM will show and hide sections based on picklist value:
function HideShowHardwareRoles() {
var typeControl = Xrm.Page.ui.controls.get(“new_type”);
if ((typeControl != “undefined”) && (typeControl != null)) {
var picklist = Xrm.Page.data.entity.attributes.get(“new_type”);
if (picklist.getValue() != null) {
var hwText = Xrm.Page.getAttribute(“new_type”).getSelectedOption().text;
//set visible based on value
switch (hwText) {
case “Server/Workstation/Laptop”:
SetVisibleSection(“Server Roles”, true);
SetVisibleSection(“Router/Firewall Roles”, false);
SetVisibleSection(“Switch Roles”, false);
SetVisibleSection(“Printer Roles”, false);
break;
case “Router/Firewall”:
SetVisibleSection(“Server Roles”, false);
SetVisibleSection(“Router/Firewall Roles”, true);
SetVisibleSection(“Switch Roles”, false);
SetVisibleSection(“Printer Roles”, false);
break;
case “Switch”:
SetVisibleSection(“Server Roles”, false);
SetVisibleSection(“Router/Firewall Roles”, false);
SetVisibleSection(“Switch Roles”, true);
SetVisibleSection(“Printer Roles”, false);
break;
case “Printer”:
SetVisibleSection(“Server Roles”, false);
SetVisibleSection(“Router/Firewall Roles”, false);
SetVisibleSection(“Switch Roles”, false);
SetVisibleSection(“Printer Roles”, true);
break;
default:
SetVisibleSection(“Server Roles”, false);
SetVisibleSection(“Router/Firewall Roles”, false);
SetVisibleSection(“Switch Roles”, false);
SetVisibleSection(“Printer Roles”, false);
break;
}
}
else {
SetVisibleSection(“Server Roles”, false);
SetVisibleSection(“Router/Firewall Roles”, false);
SetVisibleSection(“Switch Roles”, false);
SetVisibleSection(“Printer Roles”, false);
}
}
}
function SetVisibleSection(sectionname, show) {
var tab = Xrm.Page.ui.tabs.get(“General”);
var section = tab.sections.get(sectionname);
if (section != null) {
section.setVisible(show);
}
}
By: Bill Caldwell – Microsoft Dynamics CRM Denver, Colorado Partner