function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
megmooPDXmegmooPDX 

query in apex class to get all values in a multi-select picklist

I need to know how to query to get all the configured multi-select picklist values. I need it from the general field configuration, not from a specific record. I have an apex class where I am selected records from an object. I only want to select those records that contain a value configured within this multi-select picklist field. This field is not linked to, nor should it be, to the multi-select picklist. 

I'll use the below screen shot to better explain. I want to query the custom multi-picklist field to get all valid values. So looking at the screen shot below, I want the query to return (106, 107, 108, 109, 117, 119, 126, 127, 128). It seems this should be easy to do, but I can't find anything that points me in the right direction. 

User-added image

Thanks in advance for any help provideded!
Subramani_SFDCSubramani_SFDC
Hope this will help you.....

global without sharing class util
{
   // Get a list of picklist values from an existing object field.
   global static list<SelectOption> getPicklistValues(SObject obj, String fld)
   {
      list<SelectOption> options = new list<SelectOption>();
      // Get the object type of the SObject.
      Schema.sObjectType objType = obj.getSObjectType();
      // Describe the SObject using its object type.
      Schema.DescribeSObjectResult objDescribe = objType.getDescribe();      
      // Get a map of fields for the SObject
      map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
      // Get the list of picklist values for this field.
      list<Schema.PicklistEntry> values =
         fieldMap.get(fld).getDescribe().getPickListValues();
      // Add these values to the selectoption list.
      for (Schema.PicklistEntry a : values)
      {
         options.add(new SelectOption(a.getLabel(), a.getValue()));
      }
      return options;
   }