This method returns a NameValueCollection of picklist items. CrmHelper is similar to the SDK utility sample.
public NameValueCollection GetAgencyRelationshipTypePicklist()
{
CrmHelper helper = new CrmHelper();
NameValueCollection picklist = new NameValueCollection();
RetrieveAttributeRequest attribReq = new RetrieveAttributeRequest();
attribReq.EntityLogicalName = "new_agencycontact";
attribReq.LogicalName = "new_agencycontacttype";
attribReq.RetrieveAsIfPublished = true;
MetadataService service = helper.GetMetadataService();
RetrieveAttributeResponse attribResp = service.Execute(attribReq) as RetrieveAttributeResponse;
PicklistAttributeMetadata listData = attribResp.AttributeMetadata as PicklistAttributeMetadata;
foreach (Option item in listData.Options)
{
picklist.Add(item.Value.formattedvalue, item.Label.UserLocLabel.Label);
}
return picklist;
}
No comments:
Post a Comment