Global Picklist: Define Globally and use them locally

Let’s say you have to store information about t-shirt sized on various entities like Accounts,Users,custom objects etc. And after a month, your company decides to switch to a different size format, for example, 36,38,40 instead of small,medium and large. The only option you have is to go and update the picklist values everywhere its used. And if you forgot to update some of the field values, or if you did typo like “Medim” instead of “Medium” it will result into broken reports and other issues as well.

Global Picklist comes to your rescue in this type of scenario. This feature is available right out of the box in the Winter 17 release. Let’s see how you can create a picklist value set and use it across multiple fields in your Salesforce instance today.

Create a new Picklist Value Set:
Let’s say you want a picklist value set to store T-shirt Sizes and then use this picklist value set on custom fields on Accounts and Contacts in your Salesforce instance. You can find picklist Value Sets under Create Section in Classic UI or under Objects and Fields in Lightning UI.

Click New and fill out all the required fields. In the below example, you can see the global value set created to store T-shirt Sizes in my org.

Did you notice something different? You can actually view the list of fields where this particular picklist has been used. This make it easy to keep track of all the places where you have used the picklist value set.

How to use Global Value Sets on Custom Fields?
After you have created a picklist value set, now you can use it when creating custom fields (both picklist as well as multi-select picklist field types are supported,it also works with dependent picklist) on the objects you want. The process of creating field has not changed much,the main difference is shown in the screenshot below:

As you can see, now you can select if you want to use a global value set or want to specify values at a field level (just like you used to do before) . Isn’t it simple??

Interacting with Global Picklist using Metadata API

Through Metadata API, you can interact with global value sets and the fields which are using the value sets. The below code snippet will help you to understand it better:

<?xml version="1.0" encoding="UTF-8"?>
<GlobalValueSet xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Updated:This is a basic global value set.</description>
<masterLabel>Territories</masterLabel>
<customValue>
<fullName>North</fullName>
<default>true</default>
</customValue>
<customValue>
<fullName>South</fullName>
</customValue>
<customValue>
<fullName>East</fullName>
</customValue>
<customValue>
<fullName>West</fullName>
</customValue>
<sorted>true</sorted>
</GlobalValueSet>

Note: Important point to note here is that, the Metadata API representation for global value set was changed in API version 38.0. Checkout the links in the resources section of the blog post.

When to use Global Value Sets:
If you need a reusable picklist values on different fields or/and objects.
If you have 500 or fewer picklist values.

When you shouldn’t use Global Value Sets:
If the global value set is not used by more than one field.
If you require more than 500 picklist values.
If you do not want your fields to be validated when inserting via API

Checkout our courses:
Salesforce Developer Training for Beginners

Salesforce Admin Certification Course

Resources:

Streamline Picklist Maintenance with Global Picklists (Generally Available)
Global (Universal) Picklists – Idea Exchange

Leave a Reply

Close Menu
%d bloggers like this:
Skip to toolbar