How to easily create dependent Picklist(Option Set) in CRM 2011 ?
Remi Boigey, Partner Technical Consultant @ Microsoft France, did a new silverlight application in order to create Dependent Picklist by using a user friendly interface.
Solution Features
- It provides a generic, re-usable JScript library that can be used for any pair of option set fields.
- It allows for a chain of dependent option set fields. Because each dependent option set field options are filtered based on the value of another field, additional option set fields options can be filtered by the option chosen in the first dependent option set field. This allows for the possibility of a set of hierarchically dependent option set fields.
- The filtering of dependent options is set in an XML Web resource. This allows for changing the option mappings without changing the code. Editing an XML Web resource is easier for a non-developer to configure options with less opportunity to break the code.
- The solution supports multiple languages. The filtering is based solely on the data value of the options rather than any text in the options.
- Filtering works for any number of instances of an attribute control on the form.
Install the solution
Step 1 : Save the CRM solution on your disk - Download here
Step 2 : Import the solution – Settings / Solutions / Import
Click on Browse Button and select the solution DependentPickLists_1_0_0_0_managed.zip.
Click on next buttons and close the form.
Refresh the web page.
Test the solution
In order to test the solution, you can use the Case entity with the two OptionSet fields: Case Type and Priority. We will filter them as displayed in the following table:
Case Type
Priority
Question
High
Normal
Low
Problem
High
Normal
Request Normal
Low
When you finalized the mapping, click on ‘Get script’ button.
In order to use our script, you need to add a XML web ressource to the targeted entity.
Step 1
- Go to Settings / Customization / Customize the System / Web Ressources
- Click on New and fill the following attributes
- Name = Schema Name
- Display Name
- Type
- Select Data XML
- Click on ‘Text editor’ and paste your clipboard
- Save the form
Step 2
- Go to Settings / Customization / Customize the System / Entities / Case / Forms
- Open the Main Form
- Click on Form properties
- Add “gps_SDK.DepdenentOpeitonSet.js” script as available libraries
- Then, in the ‘Event Handlers’ section, add the SDK.DependentOptionSet.init function on the control Form for the event OnLoad.
- And follow the printscreens :
- Click on Add
- Function: SDK.DependentOptionSet.init
- Check ‘Pass execution context as first parameter’
‘new_Case_DependentOptionSetConfig’ The parameter is the schema name of the Web ressource we just created.
- Click on OK
- Save the Form.
- Now, we have to add a function ‘SDK.DependentOptionSet.filterDependentField’ on the onchange event of the primary field (here case type)
- Double click on the ‘Case Type"’ Field
- Select the Events Tab
- Click on Add under the Event Handlers section
- Function: SDK.DependentOptionSet.filterDependentField
- Don’t Check ‘Pass execution context as first parameter’
‘casetypecode’,’prioritycode’ Parameters are the schema name of the option set fields..
- Click on OK
- Save the Form
- Publish all customizations
- Navigate to Case Form and use the picklists : Case Type and Priority