Retrieve workflow information based on resource path

sd55

16-10-2019

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.

Accepted Solutions (1)

Accepted Solutions (1)

sd55

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

Answers (3)

Answers (3)

Ankur_Khare

MVP

16-10-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

scottm91515441

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