查询选择列表中的值

时间:2011-10-15 02:30:20

标签: dynamics-crm dynamics-crm-2011

我想查询商机中不同领料单中的值。我不想查询实际的商机,只查询选项列表中的值。因此,如果我有一个名为Source的Picklist,它的值为1,2,3,4,5。我想查询选项列表并获取这些值。这可能吗?如果是这样,你在世界上如何做到这一点?谢谢!

1 个答案:

答案 0 :(得分:3)

想出来:

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

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

int? businessid = null;

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