I have a script executing in a Start and End execution listener.
Is it possible for the script to determine which listener is being executed? (whether it is a Start or a End Event type).
execution.getEvent()
should do the trick.
1 Like
@thorben where would getEvent come from, vs getEventName
For anyones interest for future use cases.
I needed this because we were logging the Start and End of HTTP requests (and did not want to make changes to HTTP Connector at this time).
so some scripts that basically result in the function call of:
generateLog('This is a message that defaults to log level 1');
generateLog('This is a message that is set at log level 3', 'error');
followed by:
switch (execution.getEventName()) {
case "start":
generateLog('Starting HTTP Request');
break;
case "end":
generateLog('Finishing HTTP Request');
break;
}
which outputs logs such as:
{
"time": "2017-09-01T14:58:13.876Z",
"cid": "fe4fc9ef-2f29-45f2-adeb-cfc1982d005d#819485",
"level": 1,
"app": "camunda",
"version": "0.7.0",
"msg": "Starting HTTP Request",
"processDefinitionId": "efa6fe80-8f25-11e7-99ac-0242ac110008",
"processInstanceId": "f9b79815-8f25-11e7-99ac-0242ac110008",
"processDefinitionName": "Process Request",
"processDefinitionKey": "ProcessRequest",
"processParentExecutionId": null,
"processCurrentActivityName": "Do Something",
"processCurrentActivityId": "ServiceTask_1010dsd"
}
{
"time": "2017-09-01T14:58:15.766Z",
"cid": "fe4fc9ef-2f29-45f2-adeb-cfc1982d005d#819485",
"level": 1,
"app": "camunda",
"version": "0.7.0",
"msg": "Finishing HTTP Request",
"processDefinitionId": "efa6fe80-8f25-11e7-99ac-0242ac110008",
"processInstanceId": "f9b79815-8f25-11e7-99ac-0242ac110008",
"processDefinitionName": "Process Request",
"processDefinitionKey": "ProcessRequest",
"processParentExecutionId": null,
"processCurrentActivityName": "Do Something",
"processCurrentActivityId": "ServiceTask_1010dsd"
}
just FYI for anyone in the future.
It’s getEventName
, I remembered the wrong name.
1 Like