<?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 ScriptTask + TimerBoundaryEvent in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157445#M111625</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;I have a simple Activiti diagram with a ScriptTask and a TimerBoundaryEvent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can see my diagram if you open this url: &lt;/SPAN&gt;&lt;A href="http://s22.postimg.org/ueb4mrsyp/My_Process.png" rel="nofollow noopener noreferrer"&gt;http://s22.postimg.org/ueb4mrsyp/My_Process.png&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My first task is a ScriptEvent task. In this task (I use JavaScript) I would like to set a &lt;/SPAN&gt;&lt;STRONG&gt;date&lt;/STRONG&gt;&lt;SPAN&gt; variable. It represents the start time of the process. After ScriptEvent task I have some other tasks and a TimerCatchingEvent component. It is a TimerIntermediateCatchEvent. Here I want to reuse my predefined variable and set it as a timeDate property of my TimerCatchingEvent component.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my script of the ScriptEvent task:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;scriptTask id="scripttask1" name="Set timer variable" scriptFormat="javascript" activiti:autoStoreVariables="true"&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;//var now = new Date();&lt;BR /&gt;&lt;BR /&gt;// 5 minutes later&lt;BR /&gt;execution.setVariable("process_start_time", new Date((new Date()).getTime() + 5 * 60000) + "");&lt;BR /&gt;&lt;BR /&gt;// 2 months later&lt;BR /&gt;//execution.setVariable("process_start_time", today + 60);&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/scriptTask&amp;gt;&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;/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;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;BR /&gt;&lt;SPAN&gt;My TimerCatchingEvent definition:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent"&amp;gt;&lt;BR /&gt;&amp;lt;timerEventDefinition&amp;gt;&lt;BR /&gt;&amp;lt;timeDate&amp;gt;${process_start_time}&amp;lt;/timeDate&amp;gt;&lt;BR /&gt;&amp;lt;/timerEventDefinition&amp;gt;&lt;BR /&gt;&amp;lt;/intermediateCatchEvent&amp;gt;&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;/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;BR /&gt;&lt;SPAN&gt;If I use Date type in my ScriptTask I get this persist exception: &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;Couldn't serialize value 'sun.org.mozilla.javascript.internal.NativeDate@1b37a0d' in variable 'process_start_time'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In order to avoid serialization exception I convert the Date type to String with a litle trick: &lt;/SPAN&gt;&lt;STRONG&gt;+""&lt;/STRONG&gt;&lt;SPAN&gt;. It works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But now I have another exceprion: &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;couldn't resolve duedate: Invalid format: "Wed Jan 15 2014 14:33:48 GMT+010…"&lt;/SPAN&gt;&lt;SPAN&gt;. So my date format is not align to the expectation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* How can I set a Date type variable with ScriptEvent task? If I use Date type I get a serializable exeption.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* How can I set dinamically the value of the timeDate parameter of TimerCatchingEvent component via ScriptEvent task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If possible I would like to avoid to use java class for this easy function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jan 2014 14:39:44 GMT</pubDate>
    <dc:creator>soma</dc:creator>
    <dc:date>2014-01-15T14:39:44Z</dc:date>
    <item>
      <title>ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157445#M111625</link>
      <description>Hi,I have a simple Activiti diagram with a ScriptTask and a TimerBoundaryEvent.You can see my diagram if you open this url: http://s22.postimg.org/ueb4mrsyp/My_Process.pngMy first task is a ScriptEvent task. In this task (I use JavaScript) I would like to set a date variable. It represents the start</description>
      <pubDate>Wed, 15 Jan 2014 14:39:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157445#M111625</guid>
      <dc:creator>soma</dc:creator>
      <dc:date>2014-01-15T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157446#M111626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the timeDate expects an ISO8601 date. You can also use the timeDuration-property instead and specify a duration. Eg. use "PT5H" to make the timer fire in 5hours of "P15D" to have the timer fire in 10 days.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 15:15:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157446#M111626</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2014-01-15T15:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157447#M111627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The timeDuration property is not fits to the requirements because:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(1) The timer event needs to appear &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;x days&lt;/SPAN&gt;&lt;SPAN&gt; after the workflow has been started to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(2) The timer event must not appear before the subprocess is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the running time of the subprocess is longer then &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;x days&lt;/SPAN&gt;&lt;SPAN&gt; the timer event needs to appear immediately when the workflow is in the red point (please, have a look at my new image).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the workflow reaches the red point before the &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;x days&lt;/SPAN&gt;&lt;SPAN&gt; then the timer needs to wait (start date + x days - now).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Image: &lt;/SPAN&gt;&lt;A href="http://s15.postimg.org/z5u5xx8bf/My_Process_02.png" rel="nofollow noopener noreferrer"&gt;http://s15.postimg.org/z5u5xx8bf/My_Process_02.png&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In order to handle it I need to set dinamically the timeDate property. And I do not want to use java layer for this because somtimes the key user needs to modify the lenght of this time period (she redraw activiti diagram ) but they are not able to rebuild and redeploy the application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nevertheless the key users are able to modify and upload the new version of the workflow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the reason why I would like to calculate the value of timeDate property via ScriptTask and I want to put Date variable to the context of the workflow instance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thx.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 16:49:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157447#M111627</guid>
      <dc:creator>soma</dc:creator>
      <dc:date>2014-01-15T16:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157448#M111628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, so you need to make the ScriptTask convert to an ISO-8601 date, that is used in the timeDate. You can, for example, create a util-class for this in java and expose it as a "bean" in the process-engine configuration and use it in your script. This way, no java-coding needs to be done when the time to wait is modified, only the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 08:45:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157448#M111628</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2014-01-16T08:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157449#M111629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 10:51:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157449#M111629</guid>
      <dc:creator>soma</dc:creator>
      <dc:date>2014-01-16T10:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: ScriptTask + TimerBoundaryEvent</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157450#M111630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Finaly I created an groovy script. It is working very well and it is just 3 rows and it is very easy:&lt;/SPAN&gt;&lt;BR /&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="scripttask1" name="Set timer variable, time limit = 2 months" scriptFormat="groovy" activiti:autoStoreVariables="true"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;script&amp;gt;def d = new GregorianCalendar()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d.add(Calendar.MINUTE,3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execution.setVariable("process_start_time", d.getTime().format("yyyy-MM-dd'T'HH:mmZ"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/script&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/scriptTask&amp;gt;&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;And this is my timer code;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;timerEventDefinition&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;timeDate&amp;gt;${process_start_time}&amp;lt;/timeDate&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/timerEventDefinition&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/intermediateCatchEvent&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your inspiration!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 11:25:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/scripttask-timerboundaryevent/m-p/157450#M111630</guid>
      <dc:creator>soma</dc:creator>
      <dc:date>2014-01-16T11:25:39Z</dc:date>
    </item>
  </channel>
</rss>

