<?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 Persisting modified variables in scriptTask in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156680#M110913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I start a process with an output variable which is a basic HashMap. In a javascript scriptTask, I insert some values into this map as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;output.put("result", "success");&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;If I read the process variables inside an ExecutionListener at the end of the process, the result value is as expected :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;public void notify(DelegateExecution execution) throws Exception {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; String result = ((Map) execution.getVariable("output")).get("result"); // success&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the modified variable is not persisted in the DB, a HistoricVariableInstance query returns the variable state at the beginning of the process. To have the variable persisted, I have to force it manually: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;output.put("result", "success");&lt;BR /&gt;execution.setVariable("output", output);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it the intended behavior ? Do I have to manually persist all variables modifications ? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Sep 2013 15:37:18 GMT</pubDate>
    <dc:creator>thomasl</dc:creator>
    <dc:date>2013-09-05T15:37:18Z</dc:date>
    <item>
      <title>Persisting modified variables in scriptTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156680#M110913</link>
      <description>Hello, I start a process with an output variable which is a basic HashMap. In a javascript scriptTask, I insert some values into this map as follows&lt;IMG id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;utput.put("result", "success");‍‍‍If I read the process variables inside an ExecutionListener at the end of the process, the result value is as expect</description>
      <pubDate>Thu, 05 Sep 2013 15:37:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156680#M110913</guid>
      <dc:creator>thomasl</dc:creator>
      <dc:date>2013-09-05T15:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting modified variables in scriptTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156681#M110914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you aware of the autoStoreVariables attribute (described here &lt;/SPAN&gt;&lt;A href="http://www.activiti.org/userguide/index.html#bpmnScriptTask" rel="nofollow noopener noreferrer"&gt;http://www.activiti.org/userguide/index.html#bpmnScriptTask&lt;/A&gt;&lt;SPAN&gt;) ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You have to explicitly set the value to true if you want to persist values automatically in a script task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards, &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 17:20:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156681#M110914</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2013-09-06T17:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting modified variables in scriptTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156682#M110915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tijs, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your answer. Yes I had tested with this attribute and found out that it works only for variables defined in the script. In my script, the variable in already defined prior to scriptTask execution. With this attribute, modifications are persisted only if I do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;scriptTask id="success"&amp;nbsp; activiti:autoStoreVariables="true" scriptFormat="javascript"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;output.put("result", "success");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;output = output;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could it be that modifications should be detected and are not ? Please let me know if you would like a testcase to exhibit this behaviour. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Sep 2013 13:12:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156682#M110915</guid>
      <dc:creator>thomasl</dc:creator>
      <dc:date>2013-09-07T13:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Persisting modified variables in scriptTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156683#M110916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tom,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good point, I think Activiti isn't able to see the changes to the HashMap. For now I guess we have to go for the explicit call.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, you can create a JIRA for this with a test showing the issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2013 09:12:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/persisting-modified-variables-in-scripttask/m-p/156683#M110916</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2013-09-13T09:12:58Z</dc:date>
    </item>
  </channel>
</rss>

