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;
}

*****

[1222 byte] By [MariusAugust] at [2007-12-25]
# 1
Same question here. Get the same error. When/where were we supposed to create that attribute?
chaffee007 at 2007-8-31 > top of Msdn Tech,Microsoft ISV Community Center Forums,ISV Open Discussions...
# 2

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;

}

MariusAugust at 2007-8-31 > top of Msdn Tech,Microsoft ISV Community Center Forums,ISV Open Discussions...