Expand my Community achievements bar.

SOLVED

AEM 6.2 Classic : Capture comments in default email template used by workflow

Avatar

Level 8

Hi All,

The use case for us is same as mentioned in Capturing comments in default email template used by workflow in 6.2 .

Tried the solution mentioned in the above forum post, but no luck.

All the participant steps in our case is "Dynamic Participant Step". Tried multiple things in "/etc/workflow/notification/email/default/en.txt/", based on Configuring Email Notification  but no luck.

Any thoughts/pointers/reference code on this will be really helpful.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Did you try below,  mentioned at Configuring Email Notification

Comment: ${item.data.comment}\n \



Arun Patidar

View solution in original post

18 Replies

Avatar

Correct answer by
Community Advisor

Hi,

Did you try below,  mentioned at Configuring Email Notification

Comment: ${item.data.comment}\n \



Arun Patidar

Avatar

Level 8

Hi Arun,

Yes, I did try that in the OOTB /etc/workflow/notification/email/default/en.txt file. But that doesn't work.

Avatar

Level 3

Hi,

Can you try ${item.node.data.comment} ?

If not, I can try to suggest some other options.

Avatar

Level 8

Hi Endoriel,

Tried using the below.

TEST: ${item.node.data.comment}\n \

But no luck.

Any thoughts here would be helpful.

Avatar

Level 3

It should work with ${item.data.comment} since from code doing workflow.getWorkItems().get(0).getMetaDataMap().get("comment") would return the comment and in the template context "item.data" is just workItem.getMetaDataMap() so I'm not sure. I will test it later. Are you sure you are editing the correct template? Can you add successfully some of the other available variables?

If you can't get it to work I would suggest implementing your own custom version of the EMailNotificationService which is just an osgi event handler for "com/day/cq/workflow/event"

Avatar

Level 10

In that other thread - the user said the solution was  --

Use the variable ${item.data.comment} in the default en.txt

Avatar

Level 8

Hi Endoriel,

Thank you for your reply.

Tried getting the comments by adding a new variable[with various options i.e, ${item.node.data.comment}\n \, ${item.data.comment}\n \  etc] in the existing OOTB template in the path /etc/workflow/notification/email/default as mentioned in Configuring Email Notification  .

Not sure if I am missing something here. Tried multiple times with various options.

The other variables in the OOTB template gets populated correctly in the mail received.

Below is the OOTB content[/etc/workflow/notification/email/default]

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

subject=Workflow notification: ${event.EventType}

header=-------------------------------------------------------------------------------------\n \

Time: ${event.TimeStamp}\n \

Step: ${item.node.title}\n \

User: ${participant.name} (${participant.id})\n \

Workflow: ${model.title}\n \

-------------------------------------------------------------------------------------\n\n

message=Content: ${host.prefix}${payload.path.open}\n

footer=\n \

-------------------------------------------------------------------------------------\n \

View the overview in your ${host.prefix}/inbox\n \

-------------------------------------------------------------------------------------\n \

This is an automatically generated message. Please do not reply.

Avatar

Level 8

Hi All,

We are trying to implement a custom process step wherein it will send almost similar details sent by OOTB template [/etc/workflow/notification/email/default] along with the comment provided by the previous participant step.

Able to make some progress here. For example : Once step1 is completed, mail should be triggered to user2 in step2. Able to capture comments/task end date etc of step 1. Am not able to find any property in the workflow, wherein I get user2 details(who is part of  step2), to whom the mail should be sent.

Any thoughts/pointers on this will be really helpful.

Avatar

Level 10

Your 1st step is a user part step and you want to send an email to this user?

Avatar

Level 10

Ratna and I are working on this use case BTW, it will make a good article/example.

Avatar

Level 8

Hi Scott,

Since via OOTB template we are not able to extract comments provided in the previous step, we are trying to implement something very similar[ALONG WITH COMMENTS] via custom step.

However, the challenge we are facing is not being able to get the user details of the next step to which the mail[which will have comments/time etc of the previous participant step] should go to.

Also, in all our participant steps, across the workflow [we are using dynamic participant step]. Here, we are giving the group name in "Arguments" section and we have an ecma script, as provided [

function getParticipant() {

    return args[0];

}

] in "Participant Chooser", based on which it is assigned to the corresponding group.

Avatar

Community Advisor

Guys,

${item.data.comment} does works for node transitions emails when user get notification to act on step but not when email triggered for Completion/Abort jobs.

Screen Shot 2018-09-02 at 1.49.46 AM.png

Screen Shot 2018-09-02 at 1.47.33 AM.png

Screen Shot 2018-09-02 at 1.43.30 AM.png

Screen Shot 2018-09-02 at 1.43.43 AM.png



Arun Patidar

Avatar

Level 8

Hi Arun,

We are using "Dynamic Participant Step" for all the participant activities. Is it something like because of this, we are not able to use item.data.comment

Avatar

Level 8

Hi Arun,

Considering the overall factors, looks like as you mentioned, we have to go ahead with "Participant step" instead of "Dynamic Participant step".

Tried doing it via custom process step, but realized that the issue will occur if we do a "stepback" from any of the step. That will again create issues.

One thing we noticed is just after Flow Start, if we have "Participant Step" and while initiating wf from page, if we provide comments, then that that doesn't get populated via ${item.data.comment}. It is stored under "startComment" property under /etc/workflow/instances/server0/2018-09-02/instance_1/data/metaData. But we need ${item.data.comment} in that step, as it will be used if we do a "stepback" at any point of time in the workflow.

So, basically - the very first time workflow is triggered(i.e, in the above mentioned scenario), we will have an issue. At rest of the times, it will work fine, along with the "aborting/completion" limitation you mentioned.

In case, you have some pointers/solution for the "very first time workflow is triggered" thing, please do let us know.

Avatar

Level 8

Update

For the "very first time workflow is triggered", added a custom process step to get the comment values. Testing it out.

Avatar

Level 8

Hi Arun/All,

With custom process step, able to somehow get that to work. Facing another challenge, for which I have raised another query.

AEM 6.2 classic : How to use OOTB Email Templates for Workflow Notification for different workflows

Any thoughts/pointers/reference will be really helpful.