jump to navigation

Microsoft CRM 2011 Disable Fields From Picklist May 24, 2011

Posted by jarrettexpertcrm in Uncategorized.
Tags: , , , , , , , ,
3 comments


In some cases you need to disable fields based of the value of a picklist. Below is the code to achieve this.

function disableToggle()
{

var value = Xrm.Page.getAttribute(“PICKLISTFIELD”).getValue()
// First Picklist value
if (value == “100000000”)
{
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(false);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(false);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);

}
// Second picklist value
else if (value == “100000001”)
{
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(false);

}
// Third picklist value
else if (value == “100000002”)
{
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(false);

}
// Fourth picklist value
else if (value == “100000003”)
{
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(true);
Xrm.Page.ui.controls.get(“FIELD”).setDisabled(false);

}
}

Enjoy!!

– JC

For more information about Dynamics Four you can contact us at http://www.dynamics4.com