Retrieve workflow information based on resource path | Community
Skip to main content
Level 2
October 16, 2019
Solved

Retrieve workflow information based on resource path

  • October 16, 2019
  • 4 replies
  • 3324 views

Hi,

I have a requirement, if my resource is under any running workflow, i have to do some operations on resource and terminate running workflows on this resource. how do this programmatically?

Please let me know if any thoughts on this.

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 Shashisd

Hi All,

Thank you for all your replies.

I was expecting api to find running workflow instances based on the path. I found out this can be done in following way.

PayloadMap payloadMap = resolver.adaptTo(PayloadMap.class);

List<Workflow> workflowList = payloadMap.getWorkflowInstances(path, true);

4 replies

Level 3
October 16, 2019

Do you mean if your resource is the Payload of the workflow? Typically to perform operations on a resource via a workflow - you can use the AEM APIS. You would use the Workflow API to create a custom workflow step. Then you can use other APIS - ie - Asset API if the payload was an asset.

Level 3
October 16, 2019

If you do not know how to create a custom workflow step, or use an AEM API within a workflow, or other workflow-related tasks - such as using an OR split - see this DEV doc - Adobe Experience Manager Help | Invoking an Adobe Experience Manager Custom 6.4 Workflow from a web page

Ankur_Khare
Community Advisor
Community Advisor
October 16, 2019

Using ecmascript you can easily achieve this-

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

         var path = workflowData.getPayload().toString();

         var node = jcrSession.getItem(path);

        

         if (node.getPath().indexOf("/content/we-retail/us/en") >= 0) {

             return true;

         } else {

             return false;

         }   

     } else {

         return false;

     }

Please check below link for more details-

Creating Workflow Models

ShashisdAuthorAccepted solution
Level 2
October 17, 2019

Hi All,

Thank you for all your replies.

I was expecting api to find running workflow instances based on the path. I found out this can be done in following way.

PayloadMap payloadMap = resolver.adaptTo(PayloadMap.class);

List<Workflow> workflowList = payloadMap.getWorkflowInstances(path, true);