April 3, 2020
Estimated Post Reading Time ~

How to send an approval or rejection email in a CQ5/AEM page publishing workflow

The Problem
You want to send an email in a workflow to send an email to the author of a page, that a page has been approved or rejected.

The Solution1. Set up an email on your CQ5/AEM author instance with the instructions.
2. Create a new workflow by logging into the admin interface, and going to:
http://localhost:4502/libs/cq/workflow/content/console.html

3. Click on the New button in the top left-hand corner
4. Enter the title and name for your workflow. In this case:
Title: Page Approval Workflow
Name: page-approval-workflow
Click on OK.
5. Double click on the new workflow
6. You will see Step 1 as being an approval step from an administrator. You can double click on this step and change it to any group that you want to approve the article for publishing. In this case, we will keep this as an admin user.
7. on the sidekick, go to Workflow, and find the OR Split process, and drag it on just after Step 1
8. on the sidekick, go to Collaboration Workflow and find the Send Email component.
9. Drag and drop the Send Email component onto both splits of the workflow.
10. Double click on the email step on the left, and name it Approves Page, and give a description along the lines of Approve Page and sends an email to the initiator of the workflow.
11. Double click on the email step on the right, and name it Rejects Page and gives a description along the lines of Reject Page with a description along the lines of Sends an email to the initiator of the workflow that the page has been rejected.
12. Click on Save
13. Open a new browser window, and go to crxde lite by navigating to:
http://localhost:4502/crx/de
14. Go to the following directory:
/etc/workflow and create a new folder named "demoproject"
15. create a folder inside called email
16. create a new file called emailapproval.txt
17. create a new file called emailrejection.txt
18. Click Save All
19. double click on emailapproval.txt and enter something along the following lines (Only enter the parts between, but not including the <<<<<<>>>>>> characters

Note, instead of my.name@whoeveryouare.com, enter the email address you set up as the CQ Mail Service user. I.e. john.doe@gmail.com This avoids any malarkey with spam filters.

<<<<<<<<<<<<Start of File>>>>>>>>>>>>>>>

From: My Name <my.name@whoeveryouare.com>
To: ${initiator.email}
Subject: Page Approval Granted

Hi ${initiator.name},
Your page ${payload.path} has been approved and published.

Regards,
Your local friendly CQ5 Admin

-----------------------------------------
All Workflow properties:
${properties}

<<<<<<<<<<<<End of File>>>>>>>>>>>>>>>

20. Double click on emailrejection.txt and enter the following

<<<<<<<<<<<<Start of File>>>>>>>>>>>>>>>

From: My Name <my.name@whoeveryouare.com>
To: ${initiator.email}
Subject: Page Rejected

Hi ${initiator.name},
Your page ${payload.path} has been rejected. Please make changes and resubmit for approval.

Regards,
Your local friendly CQ5 Admin

<<<<<<<<<<<<End of File>>>>>>>>>>>>>>>

21. Click on Save all, and go back to your workflow window.
22. Double click on the Approve Page step
23. go to the Arguments tab, and enter the following as the email template path: /etc/workflow/demoproject/email/emailapproval.txt
24. Click OK
25. Double click on the Reject Page step
26. go to the Arguments tab, and enter the following as the email template path: /etc/workflow/demoproject/email/emailrejection.txt
27. click OK
28. Go to the sidekick, and select the WCM Workflow tag.
29. Add the activate page/asset step to the left-hand side of the OR tag, just after the approval tag.
30. Click on Save
31. Go to the user's section, and add a new user belonging to the content-authors group, with your email address specified as the user's email. You will also need to add the user to the workflow-users group.
32. In a separate browser, log in as the newly created user.
33. Go to: http://localhost:4502/siteadmin#/content/geometrixx-media/en
34. Click on the workflow button after highlighting the gadgets page.
35. Select page approval workflow and submit.
36. Go to the original browser, where you are logged in as admin, and navigate to: http://localhost:4502/inbox
37. Double click on the page, and you will see the page appear in edit mode.
38. Go back to the inbox page as in step 36, and click once on the workflow.
39. Click on complete.
40. Drop down the Next step Combox, and select reject.
41. Click OK.
42. The workflow should have been rejected at this point, and an email sent to the originator of the workflow process.
43. Repeat the process with your newly created user and resubmit the page. This time, as the admin user, approve the workflow.
44. You will see that the page has been published, and you should have received an email telling you that your page has been approved.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.