Check if list of pages are in workflow | Community
Skip to main content
Level 2
March 28, 2024
Solved

Check if list of pages are in workflow

  • March 28, 2024
  • 1 reply
  • 581 views

Hi everyone,
I came across a sling job requirement of checking if any of the pages in a list (this list will come from a TSV or CSV file stored in DAM) is in workflow or not and then do the further processing. What are the ways we can try ? And Is there any way of checking that efficiently? (there are going to be around tens of thousands of pages). 

What I have tried : (Please correct me if I'm in the wrong direction)

I was trying Payload Map, but it is returning null in the first line itself. Resource Resolver is working fine.

PayloadMap payloadMap = resourceResolver.adaptTo(PayloadMap.class);
payloadMap.isInWorkflow(resource.getPath(), true/false);

 

Thank You

 

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 lukasz-m

Hi @jangra98,

I think using WorkflowStatus class will be the best option. In general you can iterate over the list of pages and get Resource or Page object of each item from the list, and simply adapt it to WorkflowStatus to get information if given page is subject of the workflow.

 

// for Resource object WorkflowStatus ws = resource.adaptTo(WorkflowStatus.class); // gives you information if given resource is subject of workflow ws.isInRunningWorkflow(false); // gives you list of workflows that current resource is part of ws.getWorkflows(false); // the same code for Page object WorkflowStatus ws = page.adaptTo(WorkflowStatus.class); ws.isInRunningWorkflow(false); ws.getWorkflows(false);

 

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
March 28, 2024

Hi @jangra98,

I think using WorkflowStatus class will be the best option. In general you can iterate over the list of pages and get Resource or Page object of each item from the list, and simply adapt it to WorkflowStatus to get information if given page is subject of the workflow.

 

// for Resource object WorkflowStatus ws = resource.adaptTo(WorkflowStatus.class); // gives you information if given resource is subject of workflow ws.isInRunningWorkflow(false); // gives you list of workflows that current resource is part of ws.getWorkflows(false); // the same code for Page object WorkflowStatus ws = page.adaptTo(WorkflowStatus.class); ws.isInRunningWorkflow(false); ws.getWorkflows(false);