Expandir la barra de logros de la comunidad.

Create an approval workflow with many pages without having to manually select each page with the mouse (such as creating a script / macro for repetitive tasks) ?

Avatar

Level 1

Hi everyone, I have a question about creating workflows in AEM (and automating repetitive tasks in general). 

 

Our process to create a workflow in AEM is:

 

  1. Navigate to Sites > {your product's v1 folder}
  2. Select the icon for the page to be reviewed (if you need more than one page reviewed, additional pages can be added later from within the workflow). Various buttons become visible in the toolbar above, including "+Create".
  3. Click Create in the top (far left) nav. The button expands, revealing several options.
  4. Click Workflow. The Create Workflow window opens.
  5. Select Workflow Model - type 'E' or scroll to find EDP Sequential Workflow or EDP Daily Workflow. The applicable fields are displayed (workflow title, keep workflow package, package title, change summary, date, approver, publisher, etc.)
  6. (Fill out the various fields for your workflow.)
  7. If you have multiple pages to review (or your product is available to multiple countries / languages), now you can add additional pages to the workflow.
    1. Click Add content (top left). A modal opens, displaying the usual Sites landing page:
    2. Navigate to 
      {portal} > (language-specific site, e.g., "en-us") > {department} > products > {product} > v1 > {page} 
      and select another single page.
    3. Click the blue Select button at the top right to add the page.
    4.  (Repeat the above process for any additional pages. If your product is available in other countries, repeat the above process to Add content for the version(s) for those as well.)
  8. When you've added all relevant pages: Check the box next to Title to select all pages.
  9. Click Next at the top right. The pages will appear listed on the screen.
  10. Click Super Select All or Select All to select all pages. The Create button should now be enabled (turn blue).
  11. Click Create.
  12. Etc. Etc.

 

It's the steps under 7 (in red) that are killing us. To add a page you have to not just click, but navigate, 9 times to add the page. It's not uncommon for us to update 15 or more pages. We have customers in multiple countries, for example USA, Canada and Puerto Rico. Which means that we have to click [Add Content], then navigate all the way through the columns (and the navigation for each column is NOT alphabetized) to get to each page, then click the Select button, for each page under USA, then do it all over again for the Canada, then do it AGAIN for Puerto Rico. That's 9 clicks times 15 pages times 3 countries. That's enough to give anyone carpal tunnel syndrome.

 

So my question is:

How might we add many / multiple pages to the approval workflow without having to go through all the steps of manually selecting each page separately with the mouse in the UI, and instead just paste in the page paths? 

 

For example:

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-1

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-2

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-3

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-4

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-5

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-6

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-7

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-8

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-9

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-10

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-11

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-12

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-13

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-14

/content/my-portal/en-us/my-department/products/my-product/v1/my-topic-15

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-1

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-2

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-3

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-4

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-5

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-6

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-7

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-8

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-9

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-10

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-11

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-12

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-13

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-14

/content/my-portal/en-ca/my-department/products/my-product/v1/my-topic-15

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-1

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-2

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-3

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-4

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-5

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-6

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-7

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-8

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-9

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-10

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-11

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-12

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-13

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-14

/content/my-portal/en-pr/my-department/products/my-product/v1/my-topic-15

 

Surely there has to be a better way to do this?? 

 

Or in more general terms, does AEM provide some way to create a macro or script to automate these repetitive tasks? 

 

Any help would be much appreciated. 

6 Respuestas

Avatar

Level 3

The AEM Workflow Launcher (Recommended for your scenario)

 

The most common and effective AEM-native solution for automating workflows based on content changes or paths is the Workflow Launcher. This allows you to define a set of rules that, when met, automatically start a specific workflow.

 

How it helps:

 

  • Rule-Based: You can configure the launcher to start your EDP Sequential Workflow or EDP Daily Workflow when any page under a specific path (or a set of paths) is modified.

  • Path Granularity: You could set up launchers for the specific parent folder of all your product pages, e.g., /content/my-portal/*/my-department/products/my-product/v1. The * acts as a wildcard for the language folders (en-us, en-ca, en-pr).

  • Event-Driven: Instead of you initiating the process, the workflow starts automatically after a page is created, modified, or moved (the JCR Event).

 

How to implement (Conceptually):

 

  1. Navigate to the AEM Tools menu -> Workflow -> Launchers.

  2. Create a new Launcher configuration.

  3. Specify the Event Type: Typically, Modified is used for content updates.

  4. Specify the Path: Use the common parent path for your product pages, with a wildcard for the language. For example: /content/my-portal/*/my-department/products/my-product/v1.

  5. Specify the Workflow: Select your desired workflow model (e.g., EDP Sequential Workflow).

  6. Optional: Add Conditions: You can refine the trigger with conditions based on node types or properties, though simply using the path and modified event is often enough.

This means that as soon as a user saves an update to any of the 45 pages, the workflow is automatically started with that page as the payload.

Avatar

Level 10

hi @grasshopper998

If you can create a query to identify all the relevant pages, you can utilize the ACS AEM Commons Bulk Workflow Manager. This would require someone to take ownership of initiating this task, which involves a manual process that might not be ideal for your use case. 

 

Another option could be to set up a cron job to regularly check for pages that match your query and automatically assign each found page to your approval workflow. 

Here’s an example of a query to find pages where the modified date (cq:lastModified) is greater than the published date (cq:lastPublished): 

 

SELECT * FROM [cq:Page] AS page
WHERE ISDESCENDANTNODE(page, '/content/my-portal')
AND page.[cq:lastModified] > page.[cq:lastPublished]

 

 

Avatar

Level 1

Thanks for your reply. Very interesting - I don't know if I have the access to create a cron job as you describe, but I can check with our admins, maybe they can do that on our behalf. Thanks again. 

Avatar

Level 1

Thanks for your reply, I appreciate the step-by-step instructions, and will give this a try. 

Avatar

Employee

Hello @grasshopper998 
- You cannot directly paste a list of page paths into the workflow UI in AEM Sites. All selections must be made via the UI
- You can try to automate workflow initiation via workflow packages: create a plain text file with all your page paths, upload it to CRXDE, and use the workflow package servlet to turn it into a workflow package.
- The package can then be the payload for a standard workflow, processing all pages in one workflow instance
- You can also consider using ACS Commons Bulk Workflow Manager to start workflows on large sets of resources; allows batching with CSV or folder path input.
- Full automation is possible by custom scripting (Groovy Console, AEM Easy Content Upgrade to create workflow packages and launch workflows.

Avatar

Level 1

Thanks for your reply. 

 


- You cannot directly paste a list of page paths into the workflow UI in AEM Sites. All selections must be made via the UI

Yes, and that is so frustrating. A UI is okay when it comes to single items, but for business users that have a large amount of changes, it amounts to a huge waste of time. They really ought to build some shortcuts for power users who need to get a lot done and don't have time to waste clicking around endlessly with the mouse. 

 

However thanks for suggesting several alternatives to try, I will look into these! 

 

Thanks again to everyone who replied, your answers are much appreciated, and I am hopeful that your answers will provide a solution!