For collecting Picklist Options you have to use CRM’s MetaDataService.asmx as older Post.
See the below sample code snippet for collect picklist options.
RetrieveAttributeRequest request = new RetrieveAttributeRequest();//Create Obj for RetrieveAttributeRequest
request.EntityLogicalName = CrmSdk.EntityName.new_crmcustomentity.ToString();//Assign CRM's Custom Entity
request.LogicalName = "new_customattribute";//Set Obj's Picklist Attribute Name
//Now collect entity's response using Metadataservice execution
RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request);//service is MetaDataService.asmx's object
//collect Picklist Attribute Metadata value
PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.AttributeMetadata;
//here I use DropDownList for collecting PickList Options
foreach (Option o in picklist.Options)
{
objDropDownList.Items.Add(new ListItem(o.Label.UserLocLabel.Label, o.Value.Value.ToString()));
}
In my Next Post you will see how to set Picklist Option in CRM Entity Item from Custom UI.
Happy Coding !!!
No comments:
Post a Comment