cancel
Showing results for 
Search instead for 
Did you mean: 

Passing in variable timer duration

gerry_fisher
Champ in-the-making
Champ in-the-making
Does anyone know how to pass in a variable timer duration?

Here's what my definition looks like:

<process id="groupApprovalWorkflow">
  
      <startEvent id="startArtworkReview"/>
      <sequenceFlow id="startsArtworkReview" sourceRef="startArtworkReview" targetRef="reviewArtwork"/>
      <userTask id="reviewArtwork">
         <humanPerformer>
            <resourceAssignmentExpression>
              <formalExpression>${userId}</formalExpression>
            </resourceAssignmentExpression>
        </humanPerformer>
      </userTask>
      <sequenceFlow id="endsArtworkReview" sourceRef="reviewArtwork" targetRef="endArtworkReview"/>
      <endEvent id="endArtworkReview"/>
     
      <boundaryEvent attachedToRef="reviewArtwork" cancelActivity="false" id="triggerEmailReminder">
         <timerEventDefinition>
            <timeDuration>${completionDeadline}</timeDuration>
         </timerEventDefinition>
      </boundaryEvent>
      <sequenceFlow id="sendsEmailReminder" sourceRef="triggerEmailReminder" targetRef="sendEmailReminder"/>
      <serviceTask id="sendEmailReminder" activiti:class="com.kallik.process.utils.SendEmailReminder"/>
      <sequenceFlow id="continuesArtworkReview" sourceRef="sendEmailReminder" targetRef="reviewArtwork"/>
     
   </process>

Here's the code to start the process:

Map<String, String> form = new HashMap<String, String>();
form.put("userId", userId);
form.put("completionDeadline", "PT30S");
         
ProcessInstance processInstance = ProcessServices.getFormService().submitStartFormData(processDefinitionId, form);

I'm getting a thrown exception saying that ${completionDeadline} cannot be resolved. The definition works correctly when I replace ${completionDeadline} variable by the constant PT30S.
5 REPLIES 5

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise

gerry_fisher
Champ in-the-making
Champ in-the-making
Thanks; I didn't realise that it hadn't been implemented yet. Using an expression, instead of a constant, seemed the most obvious way of passing-in a value that I just assumed there was a mistake in my code. I can feel another code hack coming on.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
code hack? In Activiti? Why not contribute it? I did not start working on it yet and the code is very clear. Several other fields already accept an expression and it is almost copy paste 🙂

gerry_fisher
Champ in-the-making
Champ in-the-making
OK, I'll look at the base code next week and see if I can implement the requirement.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
I'll post some hints over the weekend