Terminate a workflow using the payload(type: JCR_PATH) in code implementation? | Community
Skip to main content
New Participant
October 16, 2015
Solved

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

  • October 16, 2015
  • 1 reply
  • 3029 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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

1 reply

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

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