我正在尝试从我的CRMOnline中获取OptionSet key=>values。我可以访问SOAP端点,并且能够执行所有CRUD操作。在如何从选项集SalesStageCode中获取信息,以便可以在外部帐户创建表单的下拉列表中显示它时,我遇到了一点麻烦。
发布于 2014-01-21 23:58:13
我相信你应该使用RetrieveAttribute消息。重新检查this article
发布于 2014-01-22 01:38:28
来自CRM 2011 Programatically Finding the Values of Picklists, Optionsets, Statecode, Statuscode and Boolean (Two Options).的C#版本
static Dictionary<String, int> GetNumericValues(IOrganizationService service, String entity, String attribute)
{
RetrieveAttributeRequest request = new RetrieveAttributeRequest
{
EntityLogicalName = entity,
LogicalName = attribute,
RetrieveAsIfPublished = true
};
RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request);
switch (response.AttributeMetadata.AttributeType)
{
case AttributeTypeCode.Picklist:
case AttributeTypeCode.State:
case AttributeTypeCode.Status:
return ((EnumAttributeMetadata)response.AttributeMetadata).OptionSet.Options
.ToDictionary(key => key.Label.UserLocalizedLabel.Label, option => option.Value.Value);
case AttributeTypeCode.Boolean:
Dictionary<String, int> values = new Dictionary<String, int>();
BooleanOptionSetMetadata metaData = ((BooleanAttributeMetadata)response.AttributeMetadata).OptionSet;
values[metaData.TrueOption.Label.UserLocalizedLabel.Label] = metaData.TrueOption.Value.Value;
values[metaData.FalseOption.Label.UserLocalizedLabel.Label] = metaData.FalseOption.Value.Value;
return values;
default:
throw new ArgumentOutOfRangeException();
}
}
OptionSetValue optionSetValue = new OptionSetValue(GetNumericValues(proxy, "new_test", "new_local")["One"]);https://stackoverflow.com/questions/21261437
复制相似问题