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...
Asked
Active
Viewed 4.6k times
2 Answers
28
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.
![](../../users/profiles/1525840.webp)
Konrad Viltersten
- 28,018
- 52
- 196
- 347
![](../../users/profiles/3409248.webp)
Renjith
- 715
- 4
- 7
-
Initially it was like ***entity.GetFormattedAttributeValue("attributename");*** Now a days it is ***entity.FormattedValues["attributename"];*** – Anish Sep 20 '18 at 13:10
2
You should put this logic in the pre-update (and maybe pre-create) steps. Retrieve the case from the Target parameter, get the display value of the option set field (there are several ways to do this, I like using the FormattedValues attribute), and set the text field to be this value.
entity["new_textfield"] = entity.FormattedValues["new_optionset"];
![](../../users/profiles/3448285.webp)
Zach Mast
- 1,633
- 1
- 9
- 17