In Activiti, how do I check if a variable is set?
Use the following expression:
${execution.getVariable('startTime') != null}
You have to set startTime variable in both cases;
variables.put("startTime", startTime);
ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, variables);
and
variables.put("startTime", null);
ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, variables);
Then check variable in gateway
<exclusiveGateway id="startGateway" default="waitSequenceFlow"/>
<sequenceFlow id="startSequenceFlow" sourceRef="startGateway" targetRef="firstTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${empty startTime}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="waitSequenceFlow" sourceRef="startGateway" targetRef="startTimer"/>
OR
You can use http://www.activiti.org/userguide/#bpmnTimerStartEvent