Expand my Community achievements bar.

SOLVED

Terminate a workflow using the payload(type: JCR_PATH) in code implementation?

Avatar

Level 2

I could find the below code while searching:

Workflow workflow = wfSession.getWorkflow(workItem.getWorkflow().getId());

wfSession.terminateWorkflow(workflow);

Is the above implementation correct to achieve the goal?

How should the definition for wfSession and workItem objects look like?

Where/How do i use the payload, to fetch the instance id of the workflow?

1 Accepted Solution

Avatar

Correct answer by
Level 10

You have access to all of these objects when writing a custom workflow step. These objects are arguments to the execute method:

public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args)

For example -- you can use this Java application logic from within the execute method:

Workflow workflow = wfSession.getWorkflow(workItem.getWorkflow().getId());

wfSession.terminateWorkflow(workflow);

Within the custom step - you have the ability to test an expression:

If (A > X)

    //DO something in the Workflow step

else

   //Termininate the workflow

To learn how to write a custom workflow step using the CQ 5.6 APIs -- see:

http://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

For more information about the Workflow APIs -- see:

https://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/workflow/exec/WorkflowProcess.html

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

You have access to all of these objects when writing a custom workflow step. These objects are arguments to the execute method:

public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args)

For example -- you can use this Java application logic from within the execute method:

Workflow workflow = wfSession.getWorkflow(workItem.getWorkflow().getId());

wfSession.terminateWorkflow(workflow);

Within the custom step - you have the ability to test an expression:

If (A > X)

    //DO something in the Workflow step

else

   //Termininate the workflow

To learn how to write a custom workflow step using the CQ 5.6 APIs -- see:

http://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html

For more information about the Workflow APIs -- see:

https://dev.day.com/docs/en/cq/current/javadoc/com/adobe/granite/workflow/exec/WorkflowProcess.html