<?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 Re: How to retrieve the the return value of the last serviceTask in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109383#M76764</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As your process is completely ended, the result (in the process variable 'myResult') is gone too, unless you set the Activiti History Level to FULL (performance impact) and use the history to retrieve the value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For synchronous process models, you can add a receive task (named 'receiveTask', see example below) right after your service task or better before your endTask. The process will afterwards wait in this receive task. Then you can query the process using the runtime service for the variable, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", input);&lt;BR /&gt;String myResult = runtimeService.getVariable(processInstance.getId(), "myResult");&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;But do not forget to signal the process afterwards to continue and finally end:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Execution execution = runtimeService.createExecutionQuery()&lt;BR /&gt;&amp;nbsp; .processInstanceId(pi.getId())&lt;BR /&gt;&amp;nbsp; .activityId("receiveTask")&lt;BR /&gt;&amp;nbsp; .singleResult();&lt;BR /&gt;runtimeService.signal(execution.getId());&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;Now the process really ended.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope it helped,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heiko&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Feb 2012 16:52:39 GMT</pubDate>
    <dc:creator>bardioc</dc:creator>
    <dc:date>2012-02-23T16:52:39Z</dc:date>
    <item>
      <title>How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109382#M76763</link>
      <description>Hi, is there a way to retrieve the return value of the serviceTask at the end of the process ?My BPMN file is as below&amp;lt;definitions id="definitions" targetNamespace="http://activiti.org/bpmn20"&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:activiti="http://activiti.org/bpmn" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;l</description>
      <pubDate>Thu, 23 Feb 2012 15:48:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109382#M76763</guid>
      <dc:creator>petercahyadi</dc:creator>
      <dc:date>2012-02-23T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109383#M76764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As your process is completely ended, the result (in the process variable 'myResult') is gone too, unless you set the Activiti History Level to FULL (performance impact) and use the history to retrieve the value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For synchronous process models, you can add a receive task (named 'receiveTask', see example below) right after your service task or better before your endTask. The process will afterwards wait in this receive task. Then you can query the process using the runtime service for the variable, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", input);&lt;BR /&gt;String myResult = runtimeService.getVariable(processInstance.getId(), "myResult");&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;But do not forget to signal the process afterwards to continue and finally end:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Execution execution = runtimeService.createExecutionQuery()&lt;BR /&gt;&amp;nbsp; .processInstanceId(pi.getId())&lt;BR /&gt;&amp;nbsp; .activityId("receiveTask")&lt;BR /&gt;&amp;nbsp; .singleResult();&lt;BR /&gt;runtimeService.signal(execution.getId());&lt;BR /&gt;&lt;/CODE&gt;&lt;SPAN&gt;Now the process really ended.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope it helped,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heiko&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 16:52:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109383#M76764</guid>
      <dc:creator>bardioc</dc:creator>
      <dc:date>2012-02-23T16:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109384#M76765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Heiko,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply, it worked as you suggested.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i guest this is the workaround for it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just wondering if there's a way to get the result variable at the end of the process (something like a return value of a method in java), because by using the receive task, we're actually 'pausing' the process so the variables get saved into DB, and when we try to retrieve the variable using the RuntimeService, this is actually making an sql call to DB which is i think a bit of an 'overhead' process just to get the result value of a process.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 23:59:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109384#M76765</guid>
      <dc:creator>petercahyadi</dc:creator>
      <dc:date>2012-02-23T23:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109385#M76766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Peter,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;actually there is not, cause a process does by its design not have a result. It simply ends, either positively, with an error or with a cancellation. A "return" value is simply not modeled by BPMN. Only while the process itself is still running, you may send messages or update databases.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 17:32:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109385#M76766</guid>
      <dc:creator>bardioc</dc:creator>
      <dc:date>2012-02-24T17:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109386#M76767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm coming up against this now.&amp;nbsp; I've not decided on an implementation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;One interim idead i had that should work within some constraints is to have a java service task that will take the 'result' variable and set it in a thread local.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That same thread local would be accessible by the calling code.&amp;nbsp; So imagine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// your BPMN&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;serviceTask id="exposeReturnValue" activiti:delegateExpression="${ p.d.x.ActivitiReturnValue.getInstance().set(myResult)}"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Map&amp;lt;String,Object&amp;gt; args = new HashMap&amp;lt;String,Object&amp;gt;();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;runtimeserviice.startProcessBykey("key", args);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// process runs and returns&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Object result = ActivitiReturnValue.getInstance().get();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ActivitiReturnValue.getInstance().remove()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has limitations in that it will only work for synchronous processes with ONE return value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, your calling code MUST clear out the ActivitiReturnValue (a custom class by the way).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll post again once i determine my final solution that i plan on using.&amp;nbsp; I don't care for this myself.&amp;nbsp; I'm working on using the historyService to pull the value via variableUpdates().&amp;nbsp; This way i'm not adding any weird behavior and i can support multiple return values (like for multiInstance sub processes).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 22:03:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109386#M76767</guid>
      <dc:creator>trevershick</dc:creator>
      <dc:date>2012-08-27T22:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109387#M76768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not sure I am understanding the problem correctly, but couldn't you simply get the value from the history service?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that we are currently introducing a new history level in activiti 5.11 which allows you to record only the "last" value of a process variable in history.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2012 05:38:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109387#M76768</guid>
      <dc:creator>meyerd</dc:creator>
      <dc:date>2012-08-28T05:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109388#M76769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Returning something from an Activiti process is a requirement for us (for an automated flow) and the workarounds that were mentioned above would help. But, are there any plans to do this more naturally which is to optionally allow processes to return 1 or more values? This would be very useful for us through the REST API where we start a process by sending some variables &amp;amp; expect a response with the results from the flow back.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.) Are there any future plans to include this feature in Activiti?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.) Has someone extended or embedded Activiti to achieve this? One approach that comes to my mind right now, would be to define a custom task "EndTaskWithResult" which will add the result variables to the Process (by extending Process to add the result variables field) which will be returned to the callee (somehow). I would love to know if someone has done this or has any ideas around this or why this isn't a good idea to begin with if that's the case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeegar Maru&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 23:49:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109388#M76769</guid>
      <dc:creator>jmaru</dc:creator>
      <dc:date>2012-08-29T23:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109389#M76770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As Daniel already pointed out, it would be a good solution to define your own REST/Web service that starts the process instance, then retrieves the value of the process variable via the history service and give the response back. We don't have plans to support this in the REST API.&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>Thu, 30 Aug 2012 06:55:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109389#M76770</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2012-08-30T06:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the the return value of the last serviceTask</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109390#M76771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One of the clean way to do it is using the Context (Wrapper classes). Pass these wrapper/context class object as an argument to the Service task. Service task will generate the result it and set it on this object which is available even after the life cycle of the process. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Class WorkflowContext{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; RequestParamClass reqParameters;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; ResponseParamClass resParameters;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Manoj&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jul 2016 09:55:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-retrieve-the-the-return-value-of-the-last-servicetask/m-p/109390#M76771</guid>
      <dc:creator>dananemanoj</dc:creator>
      <dc:date>2016-07-15T09:55:19Z</dc:date>
    </item>
  </channel>
</rss>

