Detect triggered start event

Hi,

I have a workflow with multiple message start events, and they work without any problem. Now I want to detect which one triggered the workflow to start. I need it for the following decisions.
Now I have used a script task after each of them, set a variable, and then use it in the workflow. I want to know whether there is any better solution to detect which message start event triggered the process?

Thanks,

@dooghi You can add execution listener to all the start events and set the type of start event or instance id. So that you can refer that in following tasks.

Here’s a sample code for reference:

@Component
public class EventTypeIdentifierListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution execution) throws Exception {
        if(execution.getBpmnModelElementInstance().getElementType().getTypeName().equals("<event_type>")){
            //<event_type> can be any type of start events
            execution.setVariable("startEventType",execution.getBpmnModelElementInstance().getElementType().getTypeName());
        }
    }
}
1 Like