Salesforce Tips: Query/Insert/Update Multi-Select Picklist Values Using Salesforce API

 

The above diagram shows the field dependency within a record with:

  • Mobile field – picklist datatype as the controlling field
  • Mobile models field – multi-select picklist as the dependent field

 

During data integration or migration using data loader, one would ponder on how to go around with querying and inserting fields shown above.

 

Query

To query for such specific record with the above field values, you can use the following query in the request. The order of the multi-select picklist does not matter.

SELECT FROM Account WHERE ( Mobile__c = ‘Sony Ericson’ AND Mobile_Models__c = ‘Xperia Arc; Xperia Mini’ )

 

Insert

Similarly, to insert the field values, you can include the values specified above as well.

INSERT INTO Account
VALUES (…,‘Test Account’, ‘Sony Ericson’, ‘Xperia Arc; Xperia Mini’,…)

Update

Considering we have mentioned on querying and inserting the record, updating the record follows on a similar pattern. However, you will need to keep the original fields if you plan to update more values rather than overwriting the values.

To overwrite values:
UPDATE Account
SET Mobile_Models__c = ‘Nexus; X10’

 

To update(append values):
UPDATE Account
SET Mobile_Models__c = ‘Xperia Arc; Xperia Mini;Nexus; X10’

Get in touch today to see how WDCi can help your business.