5

It is a long story as to why (related to our sales process and marketing automation system), but I need to figure out a way to map a single select picklist in a lead to a multi-select picklist in an account.

It can't be done by default, but is there a way to override that?

2

The only way to do this is with apex, either a visualforce page for lead conversion or a trigger. Here is a handy method for adding to a multiselect field:

private String AddToMultiselect(string MultiselectValue, string AddedValue) {  

    string NewMultiselectString = ''; 

    Set<string> MultiselectValueSet = new Set<string>();
    if( MultiselectValue != null ) {
        NewMultiselectString = ';' + MultiselectValue;
        MultiselectValueSet.addAll( MultiSelectValue.split(';') );
    }

    if (addedValue != null) {
        for( string newValue : AddedValue.split(';') ) {
            if ( newValue != null && !MultiselectValueSet.contains(newValue) ) {
                NewMultiselectString += ';' + newValue;     
                MultiselectValueSet.add(newValue);
            }
        }
    }

    return (NewMultiselectString == '') ? null : NewMultiselectString.substring(1); 
}
| improve this answer | |
  • 2
    You could use a database trigger to pull the value from the lead as well. Visualforce would be overkill for such a small ticket item. – sfdcfox Oct 3 '13 at 13:57
  • I'll adjust my answer, I wasn't aware that a trigger could fire on lead conversion – greenstork Oct 3 '13 at 14:02
  • 1
    Here's an improvement for your example function, too: string addToMultiselect(string msValue, string addValue) { msValue = String.isBlank(msValue)? '': msValue; string[] values = msValue.split(';'); values.add(addValue); Set<String> uniValues = new Set<String>(values), blankVals = new Set<String> { null, '' }; uniValues.removeAll(blankVals); values = new list<string>(uniValues); return string.join(values,';'); } – sfdcfox Oct 3 '13 at 14:04
  • Understanding Lead Conversion, the section about triggers. – sfdcfox Oct 3 '13 at 14:07

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.