misc-code-samples/easydependentpicklists.js
/**
 * 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"]
 *  
 */
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: " > "


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 : " > "
function initializePicklistFilter(picklists, separator, optionTree){
	var hierarchy = picklists.split("|");
	for(var i=0;i<hierarchy.length-1;i++){
		var	picklistName = hierarchy[i];
		Xrm.Page.getAttribute(picklistName).addOnChange(filterOptions);
	}
	var filteredPicklist = {
		"separator":separator,
		"optionTree":optionTree,
		"hierarchy":hierarchy
	};
	_filteredPicklists.push(filteredPicklist);
	Xrm.Page.getAttribute(hierarchy[0]).fireOnChange();
}
function initializePicklistFilter ( picklists , separator , optionTree ) { var hierarchy = picklists . split ( "|" ) ; for ( var i = 0 ; i < hierarchy . length - 1 ; i ++ ) { var picklistName = hierarchy [ i ] ; Xrm . Page . getAttribute ( picklistName ) . addOnChange ( filterOptions ) ; } var filteredPicklist = { "separator" : separator , "optionTree" : optionTree , "hierarchy" : hierarchy } ; _filteredPicklists . push ( filteredPicklist ) ; Xrm . Page . getAttribute ( hierarchy [ 0 ] ) . fireOnChange ( ) ; }
Intializes a dependent picklist hierarchy on a CRM form.
Intializes a dependent picklist hierarchy on a CRM form .
//add the filterOptions to onchange event for every picklist in the hierarchy except the last child //instantiate new filteredpicklist object and add it to the global array //fire the onchange event for the top level optionset in the hierarchy to apply the initial filter