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
Brian MacMillanBrian MacMillan 

Querying the source of a picklist field.

I have created a custom field in the account table which is populated by a picklist.  I need to query the value of the picklist itself, not the field which it populates. How do I do this? Is there a custom fields object/table I can query? If so, how do I find out the source field's name?
*** Please note, I want to query the source from which I select values for the field, not the custom field itself. ***
 
Deepak BalurDeepak Balur
Hoping this might help you:        
            List<SelectOption> options = new List<SelectOption>();
            Schema.DescribeFieldResult fieldResult = Contact.PMOC__c.getDescribe();
            List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

         for( Schema.PicklistEntry f : ple)
            {
                system.debug( 'Label:' + f.getLabel() +'Value: ' + f.getValue());
        }      



 
Brian MacMillanBrian MacMillan
Thanks for the prompt reply. This code sample is in java, however and we're using php. Also your code appears to refer to the PMOC field in the contact table, not a picklist created for the account table.. What I need to do this is: 1. Get the name of the table which contains custom picklists created for the accounts table. Is there a meta data table or object that contains this information? What is its name? 2. The name of the custom picklist in that object. If you can answer question 1, I can probably get the answer to question 2 by describing that object. Regards, Brian MacMillan
Frédéric TrébuchetFrédéric Trébuchet
Hi,

Here is a link to metadata API https://www.salesforce.com/us/developer/docs/api_meta/Content/meta_picklist.htm.
This link should help you too http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_describesobjects.htm with Java and C# examples.
For PHP https://developer-salesforce-com.secure.firelayers.com/forums?id=906F00000008sudIAA shows an example:
$obj = $this->mySforceConnection->describeSObject($objectName)->fields;

foreach($fields as $field){
    $name = $field->name;
    if($name == 'Land__c){
        $picklists = $field->picklistValues;
    }
}
Hope this helps,
Fred
Frédéric TrébuchetFrédéric Trébuchet
Hi,

If these answers helped you solve your problem, please, mark the question as Solved and kindly select the best one ;)

Thanks,
Fred