Skip to content
Groovy 33- In a Formula Field Arrange Selected Items of a Multiselect List one Under another

Arrange Multi Select Fixed Choice List Items

We have a Multi Select Fixed Choice List and we want to arrange all the selected items one under another in a formula field.

Groovy Code for Text Formula Field

        
        def result = []
        def string_val
        
        def v_displayValues = getSelectedListDisplayValues('')
        if ( != null) {
            for (int i = 0; i < v_displayValues.size(); i++) {
                if (i == 0)
                    result.add(" " + v_displayValues[i] + "\n")
                else
                    result.add(v_displayValues[i] + "\n")
            }
            string_val = substringAfter(substringBefore(result.toString(), ']'), '[')
        } else {
            string_val = ""
        }
        
        def newString = string_val.replaceAll(',', '')
        return newString
        
        

Replace <API FCL> with the API name of your Multi Select Fixed Choice List.