Monday 21 May 2012


Dynamic Picklist for case type and sub type CRM 4.0 and 2011


var otestpick_parent = Xrm.Page.getAttribute("new_casetypecode");

var iStartIndex = -1;
var iEndIndex = -1;

switch (otestpick_parent.getSelectedOption().text)
{
case "XYZ":
iStartIndex = 1;
iEndIndex = 10;
break;

}

var otestpick_child = Xrm.Page.getAttribute("new_casesubtype");

//added to fix

var currentValue = otestpick_child.getValue();

if (iStartIndex > -1 && iEndIndex > -1)
{
var oTempArray = new Array();
var iIndex = 0;
for (var i = iStartIndex; i <= iEndIndex; i++)
{
oTempArray[iIndex] = otestpick_child.originalPicklistOptions[i];
iIndex++;
}
otestpick_child.Options = oTempArray;
//added to fix
                   otestpick_child.setValue(currentValue);
otestpick_child.Disabled = false;
}
else
{
otestpick_child.setValue(null);
otestpick_child.Disabled = true;
}

No comments:

Post a Comment