index > ISV Open Discussions > Dynamic filtering of picklist values CRM 3.0

Dynamic filtering of picklist values CRM 3.0


Hi,

I would like to create dynamic filtering of picklist values in CRM 3.0.

But I have a problem for to delete dynamically my picklist option.it is really random.

// It's here my problem
var count = oSepcialisation.Options.length;
for(var i=0; i < count; i++)
{
try
{
oSepcialisation.DeleteOption(parseInt(i)); // sometime this function deletes option, sometime doesn't.
}
catch(ex){ alert(ex);}
}

-------------------------------------------------------------------------------------------------------------------------

For to reproduce the same condition, you must create 3 attributs of type picklist
- new_dev_competency (parent picklist)
- new_dev_specialisation (child picklist)
- new_dev_orginalspecialisation (must be empty)

new_dev_competency value :
value="1" text = "competency 1"
value="2" text = "competency 2"

new_dev_specialisation value :
value="1" text = "1-specialisation 1"
value="2" text = "2-specialisation 2"
value="3" text = "2-specialisation 3"
value="4" text = "1-specialisation 4"

prefixes 1- et 2- .correspond to the ID of the competence to which this specialization is linked

//Code in OnLoad() Form
var oSepcialisation = crmForm.all.new_dev_specialisation;
var oOriginal = crmForm.all.new_dev_orginalspecialisation;

//I delete all elements from my picklist
for(var i=1; i < oOriginal.Options.length; i++)
{
oOriginal.DeleteOption(i);
}
//I add all original elements
for(var i=1; i < oSepcialisation.Options.length; i++)
{
oOriginal.AddOption(oSepcialisation.OptionsIdea.Text,oSepcialisation.OptionsIdea.DataValue);
}

//Code in OnChange() of my Competency picklist

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_dev_specialisation;
oSubIndustry.originalPicklistOptions = oSubIndustry.Options;

if (crmForm.all.new_dev_competency.DataValue == null)
{
oSubIndustry.Disabled =
true;
}
else
{
oSubIndustry.Disabled =
false;
if(oSubIndustry.DataValue == null)
{
new_dev_specialisation_onchange0();
}
}
break;
}

//Code in OnChange() of my Specialisation picklist

var oCompetency = crmForm.all.new_dev_competency;
var oSepcialisation = crmForm.all.new_dev_specialisation;
var oOriginal = crmForm.all.new_dev_orginalspecialisation;
var myFilter = oCompetency.DataValue;

//I delete all elements from my picklist
// It's here my problem
var count = oSepcialisation.Options.length;
for(var i=0; i < count; i++)
{
try
{
oSepcialisation.DeleteOption(parseInt(i)); // sometime this function deletes option, sometime doesn't.
}
catch(ex){ alert(ex);}
}

//I add all original elements
var count2 = oOriginal.Options.length;
for(var i=0; i < count2; i++)
{
if(oOriginal.OptionsIdea.Text.indexOf(myFilter + '-') != -1)
{
oSepcialisation.AddOption(oOriginal.OptionsIdea.Text,oOriginal.OptionsIdea.DataValue);
}
}

Link referer :
http://blogs.msdn.com/midatlanticcrm/archive/2005/12/04/499868.aspx?CommentPosted=true#commentmessage




Michel DEGREMONT , my blog http://www.micheldegremont.com
Degremont

Hello Degremont,

Indeed your problem is the deleteOptions.

When you delete one Option in your picklist, the length is recalculated. So you can't use the index of your loop.

A solution :

var count = oSepcialisation.Options.length;
for(var i=1; i < count; i++)
{
oSepcialisation.DeleteOption(oSepcialisation
.Options[oSepcialisation.Options.length-1].DataValue);
}

Regards,

Pierre-Adrien

Pierre-Adrien

Thanks, Its works now.




Michel DEGREMONT , my blog http://www.micheldegremont.com
Degremont
reply 3

You can use google to search for other answers

 

More Articles

• History of field's value in CRM
• Sql Server 2005 Resource Kit
• VS2005: Any more CTP or RC builds to come?
• RTM - Q3 or late Q4 ?
• Problems with BSM
• military sites
• Business Scorecard Manager Test Server
• what OS are included in MSDN OS subscription?
• Business Scorecard Manager 2005 database problem
• Dimensions in BSM
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Trouble signing up for the Microsoft Emp
• Can anyone download VS Team Edition?
• What is Team Suite Trial Edition?
• tja, noch ein test...
• Business Scorecard Manager - Deploy to R
• Need Assistance from HP Filter Experts...
• Failure during install MS Score Card Man
• Installing BSC on SQL 2005 - SQL Server
• Multiparty Audio-Video conversation
• Business Scorecard Manager 2005 - Deploy
• Redistribution of SQL Server Management
• CRM 3.0 doesn´t save my settings
• Best way to promote a new product?
• Independant Awards / Approvals
• Why not just SV?

Hot Articles

• To download Messenger 8.0
• HELP: Business Scorecard Manager 2005
• Dimensions in BSM
• Trouble signing up for the Microsoft Emp
• Intersection IM and Telephone
• Move sharepoint web front-end
• % of public market applications which de
• Sharepoint workflows
• what SRTP crypto algorithm used?
• AppHung in SQL Server (SQLEXPRESS)
• Business Scorecard Manager Alerts
• Redistributing SSAS cubes
• Microsoft Ecosystem
• Sql Server 2005 Resource Kit
• how much

Recommend Articles

• my buddy
• Issue with MS 3.0 Outlook version
• What is Team Suite Trial Edition?
• NEW
• IE7 Cannot dynamic load custom cursor
• Business Scorecard Manager 2005 database
• Business Scorecard Manager 2005 Beta 2 S
• Failure during install MS Score Card Man
• % of public market applications which de
• Microsoft Ecosystem
• Public access to a Windows Live Communic
• Application Deployment Problem using GPO
• Business Scorecard Manager 2005 - OWC -
• how much
• Publishing Scorecard in BSM