5

I would like to mass update picklist values in a custom object from picklist values in a standard object.

In the absence of universal picklists, i am having to manage a few picklists in different objects. These picklists have hundreds of options and keeping them in-sync is proving to be a challenge.

Does anyone know of a way that i can update en-masse a picklist on one object from another picklist on a separate object? Either via using excel, data loader, or the api?

Thanks.

3 Answers 3

2

You could use the MetaData API to create the Picklist values. See Picklist.

Depending on your needs you could use the Declarative Metadata syntax with the Force.com Migration Tool.

2

You can also use the metadata API from apex. See here to learn how. I implemented a solution that updates a set of picklists from the contents of a custom object using this API. The code in this question gives you an example of how to update the picklists in Apex. Or you could use the metadata API from an external client (which is the more common use). In addition, you need to use the Schema.DescribeFieldResult class to pull the values out of your master picklist (getPicklistValues() instance method will get you the list of values). Note that it's only updating the picklist values and won't change the values stored with any existing records.

2
  • I'd be VERY interested to learn more about your solution..
    – Tony H.
    Jan 21, 2014 at 3:50
  • 1
    @AntonioHerrera I posted some of the code in this question
    – donmac23
    Jan 21, 2014 at 21:53
0

In lieu of Apex and the Metadata API, I use VS Code and force:source:deploy

Note, in the case where you need to mass-update or mass-replace picklist values:

  • Changing the picklist API value creates a new entry but you can change the label (not very useful in most cases)
  • Replacing a picklist (via CLI or Metadata API) value causes the old value to be marked inactive as it is no longer part of the picklist metadata.

To replace a large number of picklist values, I would:

  1. Pull the object metadata into VS Code
  2. Replace the picklist values directly in the field-meta.xml file (for ease I usually convert the xml to a csv, replace in excel then convert back)
  3. force:source:deploy back to the target environment
  4. Run a data import to update all my existing records if needed

If the object has record types which control available picklist values, the following additional steps have to be completed:

  1. Open the recordType-meta.xml and replace all picklist values to match your updates above
  2. Note that the picklist values in the recordType-meta.xml are URL-encoded (for whatever god-forsaken reason) so you will need to encode your new values accordingly.
  3. Force:source:deploy back to target org

You must log in to answer this question.

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