This is the concept based on dependency. It means one option set is dependent on another option set.
For EX:I have a requirement to display all the related values of first option set in second option set only when I select a particular label in first option set.
CONTENTS REQUIRED:
1) Jscript library
2) Form Event
3) XML Webresouce
Then we have to do the following steps
STEP 1:
Open your CRM. Create two option set fields in an entity and add the options in both fields.
Ex: My requirement is I have two option set fields named vehicle types and vehicles. When I choose an option in an vehicle type as parent option set, then I have to get the dependent fields of that particular option only in dependent option set.
Fig: entity creation
Fig: creating parent option set field
Fig: creating dependent option set field
Fig: vehicles field creation and publish ion
Add those fields to the vehicle entity form.
Publish
Fig: inserting fields to form and get published
Step 2:
Create a web resource named vehiclexml which is of xml type in our CRM solution.
Open the Visual studio and select an xml file in it and the develop the xml code for that following option sets.
Fig: vehiclexml.xml file
Fig: Creating web resource xml file
STEP 3:
Creating another web resource of java script file named DependentOptionSetSample.js
following code in that and save it.
· above Java Script file find in below link
https://msdn.microsoft.com/en-us/library/gg594433(v=crm.7).aspx
Fig: Creating web resource of Jscript
Goto main form in vehicle entity
Form properties.
In that add the library file of Jscript that was generated in web resources.
Fig: Adding Jscript file to the library
Now goto the field of parent option type and then double click on it.
It opens the event handler where we have to add the functionality of dependency.
Then go to your CRM and the test the fields on the entity that you have created.
The following output screen shots are provided here
Output Screen shots:
1) The field vehicles is locked because it is dependent on parent option set field named vehicletype.
2) Select any option in parent option field.
3)The related options will appear in the dependent option field
