+ Start a Discussion

How do I display the value of picklist from salesforce to comboBox in Visual C# through API?

How do I display the values of picklist data type from salesforce to comboBox in Visual C# through API?


Mohith Kumar ShrivastavaMohith Kumar Shrivastava
 public static List<String> getPicklistValues(String ObjectApi_name,String Field_name){ 
        List<String> lstPickvals=new List<String>();
        Schema.SObjectType targetType = Schema.getGlobalDescribe().get(ObjectApi_name);//From the Object Api name retrieving the SObject
        Sobject Object_name = targetType.newSObject();
        Schema.sObjectType sobject_type = Object_name.getSObjectType(); //grab the sobject that was passed
        Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
        Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap(); //get a map of fields for the passed sobject
        List<Schema.PicklistEntry> pick_list_values = field_map.get(Field_name).getDescribe().getPickListValues(); //grab the list of picklist values for the passed field on the sobject
        for (Schema.PicklistEntry a : pick_list_values) { //for all values in the picklist list
          lstPickvals.add(a.getValue());//add the value  to our final list
        return lstPickvals;


This method is the utility method in apex  i drafted for picking picklist values of field as we dont have exclusive API.Just pass Object name and Field name and also use this method for SOAP or REST .Let me know if you need anything more from me on this