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
Darlene BlaneyDarlene Blaney 

What is the Picklist value object name?

I would like to retrieve all of the picklist values I set up for a field on an object for display.  Does anyone know the object name to query to find this information?
Suraj GharatSuraj Gharat
You can use Apex describe call to retrive this data.
List<Schema.PicklistEntry> l =Schema.SObjectType.Object_Name.fields.Picklist_field_name.getPicklistValues();
Neetu_BansalNeetu_Bansal
Hi Darlene,

When you open your salesforce record, in the right hand side you can see one arrow, where you find 'View Fields', open this link and there you are find the field name and object name of your picklist. Now you can use below code to retrieve all the picklist values in code:

public void getPicklistValues()
{
    // Get the country picklist values using global calls
    Schema.DescribeFieldResult fieldResult = YOUR_OBJECT_NAME.YOUR_FIELD_NAME.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    
    // Iterate over list to populate the country list
    for( Schema.PicklistEntry f : ple)
    {
        f.getLabel() --> This will give label of Picklist Value
        f.getValue() --> This will give the API name of Picklist Value (Basically both are same)
    }
}

Thanks,
Neetu
Darlene BlaneyDarlene Blaney
Hi Suraj,

Thank you for your reply.  I was hoping that there was a way to retrieve the values without using a function.  So, there is no direct access to the object?
Suraj GharatSuraj Gharat
Unfortunately not, the above specified functions are little heavy to execute in terms of processing time, but the only and recommended way to access this information since this is kind of meta info.

You need picklist all the values that admin has configured for that particular field, right ?
Darlene BlaneyDarlene Blaney
Hi Suraj,

Yes, I would like all possible values.  Looks like I am going to have to rethink this...

Thank you for the information.

Thank you to Neetu as well...