cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get id of instance for a workflow ?

jeremiebal
Confirmed Champ
Confirmed Champ
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 !!!
2 REPLIES 2

kenecis
Champ in-the-making
Champ in-the-making
to jeremiebal

try this one.

logger.log("Workflow process definition id: "+task.processDefinitionId);

task.processDefinitionId will retrieve the workflow definition id

livier
Confirmed Champ
Confirmed Champ

I have the exact same problem

Does anyone have a solution ?