/** * @summary Easy dependent picklists for Dynamics CRM. * @author Lucas Alexander * @link http://www.alexanderdevelopment.net */ /** global array to hold the picklist hierarchies and data */ var _filteredPicklists = []; /** * milliseconds to delay between clearing the picklist controls and repopulating them * IE can run into problems if this is too short */ var _globalDelay = 500; /** * Intializes a dependent picklist hierarchy on a CRM form. * * @param picklists - pipe-delimited string that contains the picklists in the hierarchy in order of first parent to last child * example:"new_picklistlevel1|new_picklistlevel2|new_picklistlevel3" . * * @param separator - string used to separate levels in the parent-child option tree * example: " > " * * @param optionTree - array containing all possible parent-child option paths you want to enable on the form * example: ["1 -> 1a -> 1a1","1 -> 1a -> 1a2","1 -> 1b -> 1b1","1 -> 1c","2 -> 2a -> 2a1"] * */ function initializePicklistFilter(picklists, separator, optionTree){ var hierarchy = picklists.split("|"); for(var i=0;idown - lpa 2016-09-26 var startinglevel = 0; //create an array to hold the selected options for each picklist in the hierarchy var selectedOptions = [hierarchy.length]; //loop through the hierarchy to get the selected options, clear child options and temporarily disable the onchange event for each picklist for(var i=startinglevel;i0){ attribute.controls.forEach(function (control) { control.clearOptions(); //disable child controls until we put something in them control.setDisabled(true); }); } } //set a delay because IE is stupid - this is not necessary in Chrome! - lpa 2016-09-26 setTimeout(function(){ //represents the full path from first parent to last child - start with empty value and will build out by looping var workingPath = ""; //loop through all parent picklists to set the corresponding child options for(var i=startinglevel;i-1) { returnvalue = filteredPicklist; } }); return returnvalue; } /** Checks if a set of picklist options contains a text value and returns the found option (or null). */ function getOptionByText(options, optiontext){ var returnoption = null; options.forEach(function(option){ if(option.text==optiontext){ returnoption = option; } }); return returnoption; }