AnsweredAssumed Answered

How can i get id of instance for a workflow ?

Question asked by jeremiebal on Oct 16, 2014
Latest reply on Oct 25, 2014 by kenecis
Hello.

I would like to get the id of instance of my workflow by a javascript coded within this workflow

i've coded this script in my workflow :


var workflowActuel = workflow.getDefinitionByName("activiti$exercise11");
var workflowId = workflowActuel.getId();
var activeInstances = workflowActuel.getActiveInstances();
for each(instance in activeInstances) logger.warn("***INSTANCE : " + instance.getId());

logger.warn("*** WORKFLOW DEFINITION : " + workflowActuel.toString());
logger.warn("*** WORKFLOW DEFINITION ID : " + workflowId.toString());
logger.warn("*** NOMBRE INSTANCES : " + activeInstances.length);


By running several instances of my workflow, there is a strange reaction of my code.

In fact, for exemple, if i start 3 instances, my logs says id of 2 first instances but not the last (that which launched this workflow).
And so, if i start only one instance, the number of active instances will be zero whereas Activiti Eplorer show me ther is an active instance of my workflow.

So, my question is : <strong>how can i get the id of instance by a JS script within the workflow which created this instance ?</strong>

Thanks a lot !!!

Outcomes