One day I’ve got an interesting requirement. Generate cascading OptionSets (a few levels down) for products selection, in order to guide the sales staff in selecting the proper product as it relates to the rest of the products on the order. Interesting!
So, I’ve started with adding a few extra classification fields to the Product entity, to describe the relations. Then you add the relationships as needed.
On the client side, I’m doing the filtering using JS.
First off, in order to guide the user in making the selection, I only make visible the top drop-down, and hide the rest.
I’m using the following lines of code to make the drop-downs visible/hidden:
Next, I get the reference to the drop-down as such:
var dd1 = Xrm.Page.ui.controls.get("new_fieldname");
and I also want to get the values:
var options = dd1.getAttribute().getOptions();
Getting the Text and the Value properties of the drop-down I’m using a for loop, and reading each option:
var picklstvalue = options[i].value;
var picklsttext = options[i].text;
and then I can just remove the options I don’t want to display:
Other useful methods for this case are addOption, getDisabled, getName, setFocus.
See all methods with description and samples on MSDN at: http://msdn.microsoft.com/en-us/library/gg334266.aspx