Retrieve workflow information based on resource path

Avatar

Avatar

sd55

Avatar

sd55

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)

Avatar

Avatar

sd55

Avatar

sd55

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)

Avatar

Avatar

Ankur_Khare

MVP

Avatar

Ankur_Khare

MVP

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

Avatar

Avatar

scottm91515441

Avatar

scottm91515441

scottm91515441

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

Avatar

Avatar

scottm91515441

Avatar

scottm91515441

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.