I am trying to save the values from checkbox group in apex. I have converted the values from comma delemited to a list of strings. How can I save the values into the picklist type field. I have checkbox group of colors and there is a picklist field in the custom object which saves color options you choose at the front end.

in Lightning page

get acc_status_options() {
        return [
            { label: 'Black', value: 'Black' },
            { label: 'White', value: 'White' },
            { label: 'Red', value: 'Red' },
            { label: 'Yellow', value: 'Yellow' },
            { label: 'Green', value: 'Green' },

in apex i am receiving the parameter as comma delimited string and converting it to the list of String.

List selectedColors = colors.split(',');

How to save this multiple selected list values into the database field

MyObj obj = new MyObj(); obj.yourcolors__c = selectedColors;

insert obj;

I am getting error. Can not save record.

1 Answer 1


First, make sure your picklist is a multiselect picklist. Single option picklists won't hold multiple values correctly. Second, to assign multiple values to a multiselect picklist, you must use a single string separated by semicolons. In other words, if you want to store the values "Black" and "White" into a multiselect picklist, you would store the value as Black;White. You cannot assign a List to any kind of field in Apex.

You must log in to answer this question.

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