AnsweredAssumed Answered

Dynamically setting condition expression has no effect

Question asked by edmundjohnson on Aug 22, 2014
Latest reply on Sep 15, 2014 by jbarrez
I would like to be able to set the condition expression for a sequence flow dynamically without redeploying anything.
(inspired by this: http://stacktrace.be/blog/2013/03/dynamic-process-creation-and-deployment-in-100-lines/)
<!–break–>
To keep things simple, the flow has a condition of "${false}" on the diagram, and I attempt to set it to "${true}", using the following call:


public static void setSequenceFlowCondition(DelegateExecution execution, String sequenceFlowId, String condition) {
        RepositoryService repositoryService = execution.getEngineServices().getRepositoryService();
        String processDefinitionId = execution.getProcessDefinitionId();
        BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
        Process process = model.getMainProcess();
        SequenceFlow sequenceFlow = (SequenceFlow) process.getFlowElement(sequenceFlowId);
        // Set the condition expression for the flow
        String b = sequenceFlow.getConditionExpression();  // b = "${false}", correctly read from diagram
        sequenceFlow.setConditionExpression(condition);
        String c = sequenceFlow.getConditionExpression();  // c = "${true}
    }


The code is executed in a service task which comes before the gateway which has the sequence flow.
However, the code has no effect, the execution continues to behave as though the condition expression was "${false}"
What is happening? And can this be achieved a different way?
Activiti 5.16.

Outcomes