AnsweredAssumed Answered

Execution Level variables in a boundryEvent (timer); Workflows

Question asked by darkredd1 on Nov 27, 2013
Latest reply on Dec 5, 2013 by darkredd1
Good day,

I understand an activiti timer creates a separate process from the main process instance, though I can still access main process variables; it however cannot change their status. I have a boolean variable on the main process instance execution level which I call inside the timer, after the first call I want to change its status all round, meaning it has to be recognized by the main process instance after the timer executes.
Here is the attempt to effect this change:

<javascript>
<boundaryEvent id="approverReminder" cancelActivity="true" attachedToRef="recommendationTask">
       <timerEventDefinition>
          <timeDate>2013-11-27T13:58:00</timeDate>
       </timerEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="approvalReminderFlow" targetRef="approverReminderMail" sourceRef="approverReminder"></sequenceFlow>
   
    <scriptTask id="approverReminderMail">
       <extensionElements>
          <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
             <activiti:field name="script">
                <activiti:string>
                   logger.log(execution.getVariable('reminderRequired') + " @@@@@@@@@@@@@@@@@@@@");
                   if(execution.getVariable('reminderRequired') == true)
                   {
                      logger.log("Mail sent out ************");
                      execution.setVariable('reminderRequired', false);
                      logger.log(execution.getVariable('reminderRequired') + " @@@@@@@@@@@@@@@@@@@@");
                   }
                   else
                   {
                      logger.log("Mail already sent once cannot send again ###########");
                   }
                </activiti:string>
             </activiti:field>
          </activiti:executionListener>
       </extensionElements>
     </scriptTask>
</javascript>

The objective of this exercise is to have the script task to execute only once, since it executes every 5 minutes after the initial timer trigger.

Thank you in advance.
DarkRedd

Outcomes