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
prashant yadav 112prashant yadav 112 

Schema

Hi everyone
i m new in Salesforce..i have to fetch values of all available picklist in account object through schema.. kindly help me
Best Answer chosen by prashant yadav 112
VinayVinay (Salesforce Developers) 
Hi Prashant,

Following code sample shows how you can retrieve picklist values for the “Industry” field of the “Account” object as a list of Schema.PicklistEntry using getDescribe() and getPicklistValues():
 
// Describe the Account.Industry field
Schema.DescribeFieldResult fieldDescription = Account.Industry.getDescribe();
// Get picklist values from field description
List entries = fieldDescription.getPicklistValues();
// Do something with entries
for (Schema.PicklistEntry entry : entries) {
/*
entry.getValue()
entry.getLabel()
entry.isActive()
entry.isDefaultValue()
*/
}

Reference:
https://developer.salesforce.com/blogs/developer-relations/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Hi Prashant,

Following code sample shows how you can retrieve picklist values for the “Industry” field of the “Account” object as a list of Schema.PicklistEntry using getDescribe() and getPicklistValues():
 
// Describe the Account.Industry field
Schema.DescribeFieldResult fieldDescription = Account.Industry.getDescribe();
// Get picklist values from field description
List entries = fieldDescription.getPicklistValues();
// Do something with entries
for (Schema.PicklistEntry entry : entries) {
/*
entry.getValue()
entry.getLabel()
entry.isActive()
entry.isDefaultValue()
*/
}

Reference:
https://developer.salesforce.com/blogs/developer-relations/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
This was selected as the best answer
prashant yadav 112prashant yadav 112
Thanks Vinay..
VinayVinay (Salesforce Developers) 
Glad it helped you.  Please mark as Best Answer if above information was helpful.

Thanks,