|
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.Options .Text,oSepcialisation.Options .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.Options .Text.indexOf(myFilter + '-') != -1) { oSepcialisation.AddOption(oOriginal.Options .Text,oOriginal.Options .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 |