You need to sign in to do that
Don't have an account?
Darlene 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?
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
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?
You need picklist all the values that admin has configured for that particular field, right ?
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...