Expand my Community achievements bar.

How to terminate parent workflow through child workflow programmatically

Avatar

Level 1

I want to terminate the child workflow and parent when option is selected from child workflow.

I can terminate child workflow with below syntax

var workflowData = workItem.getWorkflowData();

if (workflowData.getPayloadType() == "JCR_PATH") {

    var workflow = workflowSession.getWorkflow(workItem.getWorkflow().getId());

   workflowSession.terminateWorkflow(workflow);

}

With this child gets terminated but it doesn't return back to parent or terminate the parent it gets stuck in that instance.

at this location (/var/workflow/instances/server0/2018-09-03_1/workflow) I can see the parent instance id, can anybody help me with the syntax to get this value from workflowdata  and terminate it as well or any other better way of terminating parent workflow ?

1565504_pastedImage_0.png

Any help would be appreciated.

Thank you in advance.

0 Replies