Jenkins - Active Choice DynamicReferenceParameter not returning list I have been trying unsuccessfully to get DynamicReferenceParameter of the Active Choice plugin to show previously selected values as list, however it either shows them on one line or it treats each symbol as a new element in the list.
hosts_script = '''
return['host1', 'host2', 'host3']
'''

properties([
    parameters([
      [$class: 'ChoiceParameter',
        choiceType: 'PT_MULTI_SELECT',
        description: 'Select one or more hosts',
        filterLength: 1,
        filterable: true,
        name: 'hosts',
        randomName: 'choice-parameter-5631314439613978',
        script: [
            $class: 'GroovyScript',
            fallbackScript: [
                classpath: [],
                sandbox: true,
                script:
                    'return[\'Could not get hosts\']'
            ],
            script: [
                classpath: [],
                sandbox: true,
                script: hosts_script,
            ]
        ]
    ],
    [$class: 'DynamicReferenceParameter', 
        choiceType: 'ET_UNORDERED_LIST', 
        description: 'These are the selected hosts', 
        name: 'Selected hosts', 
        omitValueField: false, 
        randomName: 'choice-parameter-5693388460832175', 
        referencedParameters: 'hosts',
        script: [
            $class: 'GroovyScript', 
            fallbackScript: [
                classpath: [], 
                sandbox: true, 
                script: 
                    'return[\'Could not get hosts\']'
            ], 
            script: [
                classpath: [], 
                sandbox: true,
                script: 
                    &quot;&quot;&quot;
                    //def list = hosts.replaceAll( '&quot;','\\'' )
                    //List list = hosts.collect{ '\\'' + it + '\\','}
                    //def list1 = new ArrayList(Arrays.asList(hosts))
                    List list = hosts.collect{ '\\'' + it + '\\','} 
                    //String list = hosts.inspect()

                    return list
                    &quot;&quot;&quot;
              ]
          ]
       ]
    ])
 ])

I can get this  • host1,host2
Or this:
 •'h',
 •'o',
 •'s',
 •'t',
 •'2',

Where I want this:
 • host1
 • host2

At the very end you will see what I have been playing with ... the biggest problem for me is that is impossible to use println to troubleshoot.
I figured out what was going on. The return from hosts var was a single string with comma separated hostnames host1, host2, I had to convert it to List  using the comma as delimiter. The following post How to convert comma-separated String to List? helped me with that task.
Basically the last section now reads
                script: 
                &quot;&quot;&quot;
                List&lt;String&gt; list = Arrays.asList(hosts.split(&quot;\\\\s*,\\\\s*&quot;));
                return list
                &quot;&quot;&quot;