Hello All,
Good to be back with another know how post. Lets go through a simple way to retrieve a MSCRM optionset label using fetchxml that can be used with C#/JS/SSRS.
Usual way to retrieve an optionset value in c# or JS is by using RetrieveAttributeRequest and refer this blog for the same.
RetrieveAttributeRequest - Option set label retrieval
This time, wanted to stick with old school SQL approach by using stringmap table, so replicated the same logic into fetchxml query and below is the simple fetchxml. This will be handy in SSRS report development to retrieve optionset details.
What is stringmap?
Stringmap is a table in crm which contains all the optionset options and its related details. Will write a quick article soon around stringmap and its fields 😉
Coming back to the topic, below is the fetchxml to get optionset label, hope the fields are self explanatory.
FetchXML
<fetch> <entity name="stringmap" > <attribute name="value" /> <filter type="and" > <condition attribute="objecttypecodename" operator="eq" value="account" /> <condition attribute="attributename" operator="eq" value="customertypecode" /> <condition attribute="attributevalue" operator="eq" value="2" /> </filter> </entity> </fetch>
Result
<result> <value>Consultant</value> </result>