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

ぃ、小莉子 提交于 2019-12-10 02:52:10

问题


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...


回答1:


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.




回答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"];


来源:https://stackoverflow.com/questions/23359880/retrieve-the-value-selected-in-optionset-field-and-display-ita-value-in-a-text-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!