For the standard SalesForce CRM objects like an Account or Opportunity there are bunch of standard fields of Picklist type - for example OpportunityStage

What is the best way to query current state of the picklist - i.e list of the possible values with preserved order? Should it be pure Apex or SOQL and what are the examples?

Also is there anyway I can write a trigger on a Picklist change - so when someone is changing the list I can know what was added/deleted and make some callout.


On how to query the answer is found:


Still need to understand how to create a trigger.


If I get your question right, you want to retrieve all the picklist values using SOQL query? If that's the case, the below link should actually help you. Retrieve picklist values

I'm just starting out at salesforce, so I really can't answer your second question, Sorry.

| improve this answer | |
  • Thanks! I've updated my question, however I still fight with how to implement trigger. – Sergio Kozlov Dec 26 '13 at 9:15

@cartman answered the first question, which is just using the Schema Describe.

For the second question, Triggers don't fire on metadata changes, only data changes. In order to audit picklist values changing, you would need to do something with the Metadata API if you wanted to query for changes programmatically and act accordingly. If you want something out of the box, you could look at the Setup Audit Trail periodically.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.