Expand my Community achievements bar.

SOLVED

Retrieve workflow information based on resource path

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 2

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);

View solution in original post

4 Replies

Avatar

Level 3

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.

Avatar

Level 3

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 ...

Avatar

Community Advisor

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

Avatar

Correct answer by
Level 2

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);