<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to pass and display an array in the workflow's task? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-pass-and-display-an-array-in-the-workflow-s-task/m-p/37920#M16009</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;After starting a workflow I &lt;STRONG&gt;populate ArrayList&amp;lt;String&amp;gt;&lt;/STRONG&gt; in the TaskLsitener and i want to &lt;STRONG&gt;show its content in the workflow's tasks&lt;/STRONG&gt;. How can i achieve that?&lt;/P&gt;&lt;P&gt;Freemarker supports arrays so creating an ftl shouldn't be a problem.&lt;/P&gt;&lt;P&gt;I can create variable of type "d:any" in the model, pass the value in the TaskListener but how to can retrive that values in the Freemarker template ?&lt;/P&gt;&lt;P&gt;So far I have created:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TaskListener&lt;/EM&gt;:&lt;/P&gt;&lt;PRE&gt;List&amp;lt;String&amp;gt; myArray = new ArrayList&amp;lt;&amp;gt;();
// ..... (populating the array)
((ExecutionEntity)delegateTask.getExecution()).getProcessInstance().setVariable("my_myDataTest",myArray);&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Model:&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;property name="my:myDataTest"&amp;gt;
   &amp;lt;type&amp;gt;d:any&amp;lt;/type&amp;gt;
   &amp;lt;mandatory&amp;gt;false&amp;lt;/mandatory&amp;gt;
&amp;lt;/property&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Template&lt;/EM&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;div id="${fieldHtmlId}-buttons"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;#list field.value as item&amp;gt;
    &amp;lt;b&amp;gt; ${item} &amp;lt;/b&amp;gt;&lt;BR /&gt; &amp;lt;/#list&amp;gt;
&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;I tried that&amp;nbsp; but I'm getting an error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;my-project     | 2020-04-09 20:18:57,721  ERROR [freemarker.runtime] [http-nio-8080-exec-3] Error executing FreeMarker template
my-project     | FreeMarker template error:
my-project     | For "#list" list source: Expected a collection or sequence, but this evaluated to a string (wrapper: f.t.SimpleScalar):
my-project     | ==&amp;gt; field.value [in template "com/epmflow/my-data-test.ftl" at line 7, column 10]&lt;BR /&gt;
my-project     | The failing instruction (FTL stack trace):
my-project     | ----------
my-project     |  ==&amp;gt; #list field.value as city [in template "com/epmflow/my-data-test.ftl" at line 7, column 3]
my-project     |     #include "\${field.control.template}"  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderField" at line 91, column 7]
my-project     |     @renderField field=form.fields[item.id]  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 122, column 13]
my-project     |     #else  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 121, column 10]
my-project     |     #else  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 117, column 4]
my-project     |     @formLib.renderSet set=item  [in template "org/alfresco/components/form/form.get.html.ftl" at line 39, column 28]
my-project     |     #if item.kind == "set"  [in template "org/alfresco/components/form/form.get.html.ftl" at line 37, column 22]
my-project     |     #nested  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderFormContainer" at line 64, column 10]
my-project     |     @formLib.renderFormContainer formId=f...  [in template "org/alfresco/components/form/form.get.html.ftl" at line 35, column 16]
my-project     |     #else  [in template "org/alfresco/components/form/form.get.html.ftl" at line 30, column 13]
my-project     |     #elseif form?exists  [in template "org/alfresco/components/form/form.get.html.ftl" at line 20, column 10]
my-project     |     @uniqueIdDiv  [in template "org/alfresco/components/form/form.get.html.ftl" at line 15, column 7]
my-project     |     @markup id="html"  [in template "org/alfresco/components/form/form.get.html.ftl" at line 14, column 4]
my-project     |     @standalone  [in template "org/alfresco/components/form/form.get.html.ftl" at line 1, column 1]
my-project     | ----------&lt;/PRE&gt;&lt;P&gt;When i use &lt;EM&gt;api-explorer&lt;/EM&gt;, i can get the value (it's &lt;STRONG&gt;not&lt;/STRONG&gt;&amp;nbsp;a string)&lt;/P&gt;&lt;PRE&gt;      {
        "entry": {
          "name": "my_myDataTest",
          "type": "d:any",
          "value": [
            "one",
            "two",
            "three",
            "four"
          ]
        }&lt;/PRE&gt;&lt;P&gt;EDIT. I checked that the value is passed as a string "&lt;EM&gt;one,two,three,four&lt;/EM&gt;". I can of couse split it by "," but then i could not use commas in the array. Is there a better way?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2020 20:34:49 GMT</pubDate>
    <dc:creator>upforsin</dc:creator>
    <dc:date>2020-04-09T20:34:49Z</dc:date>
    <item>
      <title>How to pass and display an array in the workflow's task?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-pass-and-display-an-array-in-the-workflow-s-task/m-p/37920#M16009</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;After starting a workflow I &lt;STRONG&gt;populate ArrayList&amp;lt;String&amp;gt;&lt;/STRONG&gt; in the TaskLsitener and i want to &lt;STRONG&gt;show its content in the workflow's tasks&lt;/STRONG&gt;. How can i achieve that?&lt;/P&gt;&lt;P&gt;Freemarker supports arrays so creating an ftl shouldn't be a problem.&lt;/P&gt;&lt;P&gt;I can create variable of type "d:any" in the model, pass the value in the TaskListener but how to can retrive that values in the Freemarker template ?&lt;/P&gt;&lt;P&gt;So far I have created:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TaskListener&lt;/EM&gt;:&lt;/P&gt;&lt;PRE&gt;List&amp;lt;String&amp;gt; myArray = new ArrayList&amp;lt;&amp;gt;();
// ..... (populating the array)
((ExecutionEntity)delegateTask.getExecution()).getProcessInstance().setVariable("my_myDataTest",myArray);&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Model:&lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;&amp;lt;property name="my:myDataTest"&amp;gt;
   &amp;lt;type&amp;gt;d:any&amp;lt;/type&amp;gt;
   &amp;lt;mandatory&amp;gt;false&amp;lt;/mandatory&amp;gt;
&amp;lt;/property&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;Template&lt;/EM&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;div id="${fieldHtmlId}-buttons"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;#list field.value as item&amp;gt;
    &amp;lt;b&amp;gt; ${item} &amp;lt;/b&amp;gt;&lt;BR /&gt; &amp;lt;/#list&amp;gt;
&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;P&gt;I tried that&amp;nbsp; but I'm getting an error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;my-project     | 2020-04-09 20:18:57,721  ERROR [freemarker.runtime] [http-nio-8080-exec-3] Error executing FreeMarker template
my-project     | FreeMarker template error:
my-project     | For "#list" list source: Expected a collection or sequence, but this evaluated to a string (wrapper: f.t.SimpleScalar):
my-project     | ==&amp;gt; field.value [in template "com/epmflow/my-data-test.ftl" at line 7, column 10]&lt;BR /&gt;
my-project     | The failing instruction (FTL stack trace):
my-project     | ----------
my-project     |  ==&amp;gt; #list field.value as city [in template "com/epmflow/my-data-test.ftl" at line 7, column 3]
my-project     |     #include "\${field.control.template}"  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderField" at line 91, column 7]
my-project     |     @renderField field=form.fields[item.id]  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 122, column 13]
my-project     |     #else  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 121, column 10]
my-project     |     #else  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderSet" at line 117, column 4]
my-project     |     @formLib.renderSet set=item  [in template "org/alfresco/components/form/form.get.html.ftl" at line 39, column 28]
my-project     |     #if item.kind == "set"  [in template "org/alfresco/components/form/form.get.html.ftl" at line 37, column 22]
my-project     |     #nested  [in template "org/alfresco/components/form/form.lib.ftl" in macro "renderFormContainer" at line 64, column 10]
my-project     |     @formLib.renderFormContainer formId=f...  [in template "org/alfresco/components/form/form.get.html.ftl" at line 35, column 16]
my-project     |     #else  [in template "org/alfresco/components/form/form.get.html.ftl" at line 30, column 13]
my-project     |     #elseif form?exists  [in template "org/alfresco/components/form/form.get.html.ftl" at line 20, column 10]
my-project     |     @uniqueIdDiv  [in template "org/alfresco/components/form/form.get.html.ftl" at line 15, column 7]
my-project     |     @markup id="html"  [in template "org/alfresco/components/form/form.get.html.ftl" at line 14, column 4]
my-project     |     @standalone  [in template "org/alfresco/components/form/form.get.html.ftl" at line 1, column 1]
my-project     | ----------&lt;/PRE&gt;&lt;P&gt;When i use &lt;EM&gt;api-explorer&lt;/EM&gt;, i can get the value (it's &lt;STRONG&gt;not&lt;/STRONG&gt;&amp;nbsp;a string)&lt;/P&gt;&lt;PRE&gt;      {
        "entry": {
          "name": "my_myDataTest",
          "type": "d:any",
          "value": [
            "one",
            "two",
            "three",
            "four"
          ]
        }&lt;/PRE&gt;&lt;P&gt;EDIT. I checked that the value is passed as a string "&lt;EM&gt;one,two,three,four&lt;/EM&gt;". I can of couse split it by "," but then i could not use commas in the array. Is there a better way?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 20:34:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-pass-and-display-an-array-in-the-workflow-s-task/m-p/37920#M16009</guid>
      <dc:creator>upforsin</dc:creator>
      <dc:date>2020-04-09T20:34:49Z</dc:date>
    </item>
  </channel>
</rss>

