If you come from a SharePoint background like me you will know how often you need to choose between choice lists, lookup lists and managed metadata fields. 3 ways to feed a drop down. Within the Common Data Service we also have a drop down option available. As we saw in Entities in the Common Data Service – Part 2 we can create fields of all sorts of types. One of these types is the Option Set.
Today in my series of posts about the CDS, I’m looking at option sets.
To Create an option set field in an entity you simply need to select Option Set or Multi Select Option Set and then there is of course the Two options and Lookup to consider as well.
First I’m selecting the Two Options for a field called Left Hand Drive.
Although this is not an option set it does help me introduce the set of options field types available in the CDS.
Similar to the Two options I can also create the fields using the Option Set as a data type and then oneof the available options is a Yes or No boolean. Similarly I could also create a new option set and add a Yes or No as the options available. Before you know it you will have 20 yes/no option sets.
I hope that it is clear that you should want to reuse what is there. Rather than just creating new option sets for every drop down that you can think of.
Custom Option Sets
Now that we know that we should first check if an option set already exists, we can look at creating new ones. I want to create an option set for Colour and I can do this by selecting the +New option set.
You can now add all the items in your choice list. In my case I’m going to add 5 options. Don’t worry too much about getting all the options, you can always add more later.
Within the Option Sets overview you can now find the option set that you created back. It is easy to find the ones that you created by checking the Type column. The custom ones are marked as Custom.
Multi Select Option Sets
In my above example I considered how to create an option set for the colour of my cars. Stupid me, I didn’t consider multi coloured cars. Do I now have to recreate my option set?
You can simply create a new field ( I’m calling it colours) and after selecting Multi Select Option Set and I can now reuse my Colour option set that I created earlier