Dynamick picklist in MS CRM 3.0

Let's start from the Error message:

'originalPicklistOptions' is null or not an object'

I am trying to create a classic Sector and Sub Sector dependancy.

Marius

*****

var oIndustry = crmForm.all.new_sector;

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

switch (oIndustry.SelectedText)
{
   case "Agriculture":
      iStartIndex = 1;
      iEndIndex = 2;
      break;

   case "Automotive":
      iStartIndex = 3;
      iEndIndex = 5;
      break;

 case "Food Drink & Tabacco":
      iStartIndex = 6;
      iEndIndex = 9;
      break;
}

var oSubIndustry = crmForm.all.new_subsector;

if (iStartIndex > -1 && iEndIndex > -1)

{
   var oTempArray = new Array();
   var iIndex = 0;

  for (var i = iStartIndex; i <= iEndIndex; i++)

    {
      oTempArray[iIndex] = oSubIndustry.originalPicklistOptionsIdea;
      iIndex++;
    }

  oSubIndustry.Options = oTempArray;

   oSubIndustry.Disabled = false;
}

else

{
   oSubIndustry.DataValue = null;
   oSubIndustry.Disabled = true;
}

*****




Answer this question

Dynamick picklist in MS CRM 3.0

  • Dasa

    Same question here. Get the same error. When/where were we supposed to create that attribute
  • su45937

    I've found the solution:

    Include additional code on the Form onLoad event:

    var CRM_FORM_TYPE_CREATE = 1;

    var CRM_FORM_TYPE_UPDATE = 2;

    switch (crmForm.FormType)

    {

    case CRM_FORM_TYPE_CREATE:

    case CRM_FORM_TYPE_UPDATE:

    var oSubIndustry = crmForm.all.new_subsector;

    oSubIndustry.originalPicklistOptions = oSubIndustry.Options;

    if (crmForm.all.new_sector.DataValue == null)

    {

    oSubIndustry.Disabled = true;

    }

    else

    {

    var currentValue = oSubIndustry.DataValue

    new_sector_onchange0();

    oSubIndustry.DataValue = currentValue

    }

    break;

    }



  • Dynamick picklist in MS CRM 3.0