var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
var CRM_FORM_TYPE_QUICKCREATE = 5;
// Only enable the dynamic picklist on a Create or Update form. Disabled and
// read-only forms are not editable and so do not require dynamic picklists.
switch (crmForm.FormType)
{
case CRM_FORM_TYPE_CREATE:
case CRM_FORM_TYPE_UPDATE:
case CRM_FORM_TYPE_QUICKCREATE:
var oresoucedetail = crmForm.all.nc_ownershipcodedetail;
oresoucedetail.originalPicklistOptions = oresoucedetail.Options;
if (crmForm.all.nc_ownershipcode.DataValue == null)
{
oresoucedetail.Disabled = true;
}
else
{
var oresouce = crmForm.all.nc_ownershipcode;
var iStartIndex = -1;
var iEndIndex = -1;
switch (oresouce.SelectedText)
{
case "A级":
iStartIndex = 1;
iEndIndex = 8;
break;
case "B级":
iStartIndex = 9;
iEndIndex = 12;
break;
case "C级":
iStartIndex = 13;
iEndIndex = 16;
break;
}
var oresoucedetail = crmForm.all.nc_ownershipcodedetail;
if (iStartIndex > -1 && iEndIndex > -1)
{
// Create a new array, which will hold the new picklist options
var oTempArray = new Array();
// Initialize the index for the temp array
var iIndex = 0;
// Now loop through the original resoucedetail options, pull out the
// requested options a copy them into the temporary array.
for (var i = iStartIndex; i <= iEndIndex; i++)
{
oTempArray[iIndex] = oresoucedetail.originalPicklistOptions[i];
iIndex++;
}
oresoucedetail.Options = oTempArray;
oresoucedetail.Disabled = false;
}
else
{
oresoucedetail.DataValue = null;
oresoucedetail.Disabled = true;
}
}
break;
}