retrieve the value selected in optionset field and display ita value in a text field

user3518716 picture user3518716 · Apr 29, 2014 · Viewed 44.8k times · Source

Could any one please help me in displaying an optionset field value in a text field..? I want to retrieve the value selected in optionset and display the same in a text field using plugin.. Iam writing this plugin on "update" of "case' entity...

Answer

Renjith picture Renjith · Apr 30, 2014

For getting the option set value:

int value = ((OptionSetValue)entity["yourattributename"]).Value;

For getting the text:

String text = entity.FormattedValues["yourattributename"].ToString();

In the above code entity is the Entity object from which the optionset value/text to be retrieved. Please replace the attribute name with your case.