Importing into a Salesforce Multi-Picklist

update records with javascript button
Update Records with JavaScript Buttons for Salesforce
October 25, 2013
salesforce profiles
Getting Salesforce Profiles Under Control
June 10, 2014

Importing into a Salesforce Multi-Picklist

salesforce multi-picklist
Applies to: Lightning and Classic

Ever need to update Salesforce records that have multi-picklists without fear of overriding the existing data in those pick lists? Here’s a simple solution for you.

In my example below we’ll assume we have a Salesforce multi-picklist called Product_Interest__c on the Contact object.

Create a new custom text field on the Contact object to capture the data to be imported. I recommend labeling the field the same as the multi-picklist field name plus “import”. So in our example, that would be Product_Interest_Import__c. This puts the fields alphabetically next to each other when using your import tool making it easy to remember NOT to import data into the multi-picklist field.

Next create a Contact Before Update trigger and place the following code in the trigger (modifying the field names to match your fields):

&amp;lt;br /&amp;gt;for (Contact c: {&amp;lt;br /&amp;gt;// update Product_Interest__c multi-picklist if a new value is being imported&amp;lt;br /&amp;gt;string pl = c.Product_Interest__c;&amp;lt;/p&amp;gt;<br>
&amp;lt;p&amp;gt;if (c.Product_Interest_Import__c != null) {&amp;lt;br /&amp;gt;string pli = c.Product_Interest_Import__c.trim();&amp;lt;br /&amp;gt;if (pl == null) {&amp;lt;br /&amp;gt;pl = pli;&amp;lt;br /&amp;gt;} else {&amp;lt;br /&amp;gt;if (pl.contains(pli)) { // do nothing&amp;lt;br /&amp;gt;} else {&amp;lt;br /&amp;gt;pl = pl + ';' + pli;&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;}&amp;lt;/p&amp;gt;<br>
&amp;lt;p&amp;gt;// reset the import field to empty so it doesn't attempt reprocess the import data&amp;lt;br /&amp;gt;c.Product_Interest_Import__c = null;&amp;lt;br /&amp;gt;}&amp;lt;/p&amp;gt;<br>
&amp;lt;p&amp;gt;// set the multi-picklist to their new value&amp;lt;br /&amp;gt;c.Product_Interest__c = pl;&amp;lt;br /&amp;gt;}&amp;lt;br /&amp;gt;

When you import your data, use your new Import (product_Interest__c) field. The trigger reads then import field, checks the multi-picklist field to see if it exist, if it doesn’t then in appends the import field into the Salesforce multi-picklist field.

Pretty simple and makes the import so much easier.

Terry Miller
Terry Miller
Terry has spent over 20 years focused on business leadership and information technology. As an independent consultant, he enjoys working with a variety of customers to help them solve business problems using the Salesforce® platform. His ability to quickly identify bottlenecks and provide understandable solutions has gained him the trust of his customers. If you're looking for expert guidance on your next Salesforce® project, click here to contact Terry today.


  1. Multi-select picklist importing solution | BenderForce says:

    […] Multi-select picklist importing solution […]

  2. Gregory Smith says:

    I love your blog

    I have read this article and enjoyed it

Leave a Reply