查询选项列表的描述值 [英] Query the Description Value of a Picklist

查看:78
本文介绍了查询选项列表的描述值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从CRM中选择列表的描述字段中获取值,这就是我用来获取标签值的原因,我将如何更改它以获取描述值?

I am trying to get the value from the Description field of a picklist in CRM, this is what I am using to get the Label value, how would I change it to get the Description Value?

RetrieveAttributeRequest request = new RetrieveAttributeRequest();
request.EntityLogicalName = "opportunity";
request.LogicalName = "country";

RetrieveAttributeResponse response = (RetrieveAttributeResponse)orgService.Execute(request);
PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.AttributeMetadata;

foreach (OptionMetadata option in picklist.OptionSet.Options)
    {
        string picklistlabel =  option.Label.UserLocalizedLabel.Label.ToString();

        if (p.Column_16.ToString().ToUpper() == picklistlabel.ToString().ToUpper())
            {
                 countryid= option.Value;
            }
    }

谢谢!

推荐答案

您可以通过访问 Description 属性在选项集中找到特定选项的描述。

You can find the description for a specific option in a optionset by accessing the Description property.

就像这样:

字符串描述= option.Description.UserLocalizedLabel.Label。 ToString();

此处 PicklistAttributeMetadata 公开的成员列表。

这篇关于查询选项列表的描述值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆