When trying to assign values to a multi-picklist field in test class, I'm facing the above error. Please take a look below my controller and test class.


    List<String> issues = (List<String>) JSON.deserialize(caseDetail.Test__c, List<String>.class);
    for(String strIssue : issues) {
        if(delimiter == '' || delimiter == null) {
            delimiter = strIssue;
        else {
            delimiter += ';' + strIssue;
    NewCaseToUpdate.Test__c = delimiter;

Test class :

    List<String> issueList = new List<String>();
    issueList.add('Engineering Samples');
    testCase.Test__c = JSON.serialize(issueList);
  • You are setting an invalid picklist value to Test__c, please add one of a valid value. Jun 15, 2020 at 11:28
  • 1
    Usually, the first step would be to add some system.debug() lines so you can get an idea of what data variables hold, what the result of a boolean operation is, etc... Setting that aside, is there a reason why you're not using String.join() in your controller?
    – Derek F
    Jun 15, 2020 at 11:37
  • @Rahul, 'Engineering Samples' is a valid picklist value in that field
    – sfdcOwl
    Jun 15, 2020 at 11:49

1 Answer 1


You don't need to serialize a string list into a JSON list to store the values in your field. Multi-picklist fields use the ; character to separate the selected values.

You are trying to assign a list like this:

["Engineering Samples"]

While your field likely expects just a single value like this:

"Engineering Samples"

Or, if you want to test multiple values, you should assign them like this:

"Engineering Samples"; Others; "Butterfly Samples"

Notice: they are separated by ;. If a value does not contain a space, and if it isn't even surrounded by double quotes.

From the documentation:

Multi-select picklist fields contain a list of one or more items from which a user can choose multiple items. One of the items can be configured as the default item. Selections are maintained as a string containing a series of attributes delimited by semicolons. For example, a query can return the values of a multivalue picklist as “first value; second value; third value”. For information on querying multi-select picklists, see Querying Multi-Select Picklists in the Salesforce SOQL and SOSL Reference Guide.

More here: Querying Multi-Select Picklists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.