3

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.

UPDATE

On how to query the answer is found:

  SomeObject.SomePicklistField.getDescribe().getPickListValues();

Still need to understand how to create a trigger.

2 Answers 2

3

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.

1
  • Thanks! I've updated my question, however I still fight with how to implement trigger. Dec 26, 2013 at 9:15
2

@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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .