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:

<boundaryEvent id="approverReminder" cancelActivity="true" attachedToRef="recommendationTask">
    <sequenceFlow id="approvalReminderFlow" targetRef="approverReminderMail" sourceRef="approverReminder"></sequenceFlow>
    <scriptTask id="approverReminderMail">
          <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
             <activiti:field name="script">
                   logger.log(execution.getVariable('reminderRequired') + " @@@@@@@@@@@@@@@@@@@@");
                   if(execution.getVariable('reminderRequired') == true)
                      logger.log("Mail sent out ************");
                      execution.setVariable('reminderRequired', false);
                      logger.log(execution.getVariable('reminderRequired') + " @@@@@@@@@@@@@@@@@@@@");
                      logger.log("Mail already sent once cannot send again ###########");

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.