-
1. Re: How to access e.g. startdate from Script Task?
abhijithumbe Dec 9, 2015 6:30 AM (in response to jimmy001)1 of 1 people found this helpfulYou can try with below code:
org.jbpm.process.instance.impl.ProcessInstanceImpl p = (org.jbpm.process.instance.impl.ProcessInstanceImpl)kcontext.getProcessInstance();
org.jbpm.process.audit.ProcessInstanceLog log = (org.jbpm.process.audit.ProcessInstanceLog) p.getMetaData().get("ProcessInstanceLog");
System.out.println("Start Date:"+log.getStart());
Similarly you can print user who started processinstance, and other details.
-
2. Re: How to access e.g. startdate from Script Task?
jimmy001 Dec 9, 2015 9:00 AM (in response to abhijithumbe)No, the map doesn't contain an element with the matching key. The only entries I could find in the code are:
subprocessnode:
((ProcessInstanceImpl) processInstance).setMetaData("ParentProcessInstanceId", getProcessInstance().getId());
((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeInstanceId", getUniqueId());
((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeId", getSubProcessNode().getUniqueId());
startInstance:
((ProcessInstanceImpl) processInstance).setMetaData("ParentProcessInstanceId", parentProcessInstanceId);
-
3. Re: How to access e.g. startdate from Script Task?
abhijithumbe Dec 9, 2015 9:31 AM (in response to jimmy001)Can you specify what exactly you are trying to print from Script Task. Code snip provided in above comment will print date and time when process instance is started like as:
~~~
INFO [stdout] (http-localhost.localdomain/127.0.0.1:8080-5) Start Date:Wed Dec 09 20:00:13 IST 2015
~~~
-
4. Re: How to access e.g. startdate from Script Task?
jimmy001 Dec 10, 2015 4:30 AM (in response to abhijithumbe)I have checked the code base and verified, that the lines you posted work, if you use them before the first human task.
This is because in "JPAWorkingMemoryDbLogger.beforeProcessStarted" the following line is executed:
((ProcessInstanceImpl) event.getProcessInstance()).getMetaData().put("ProcessInstanceLog", log);
Otherwise the following line is executed (e.g. beforeNodeTriggered):
NodeInstanceLog log = (NodeInstanceLog) ((NodeInstanceImpl) event.getNodeInstance()).getMetaData().get("NodeInstanceLog");
-
5. Re: How to access e.g. startdate from Script Task?
jimmy001 Dec 11, 2015 3:40 AM (in response to jimmy001)I ended up by overriding beforeNodeTriggered in a custom audit logger and put it into the metadata map.
Thx Abhijit Humbe for giving the basic idea.