Send Email workflow step comments in an email to initiator | Community
Skip to main content
Level 3
October 16, 2015
Solved

Send Email workflow step comments in an email to initiator

  • October 16, 2015
  • 5 replies
  • 2143 views

I am setting up am approval/reject workflow to authorise activations. I am setting up an email template to send the initiator to let them know if the activation has been rejected. I would like to include the "comments" that can be put in the "Participant Step", if they decide to reject the request. Is there a way to do this? Will the "Send Email" step pickup the comments from the previous "Participant Step" that causes the rejection?

So far in the email template I have,

From: Global IT activation workflow <noreply@blah.com>
To: ${initiator.email}
Subject: Activation workflow rejection

Dear ${initiator.name},

The following item you submitted for activation approval has been rejected by one of the workflow approvers
${payload.path}

Please review the item and resubmit if required, taking notice of any comments below

Thank you
CQ Administration

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 WillMc1

Hi,

If the comment you want to include is available in workflow instance metadata you can access it like this:

${item.workflow.data.[metadata property name]}

Hope this helps,

Will

5 replies

WillMc1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Hi,

If the comment you want to include is available in workflow instance metadata you can access it like this:

${item.workflow.data.[metadata property name]}

Hope this helps,

Will

Rich_ClemAuthor
Level 3
October 16, 2015

No sorry, its in the actual step item details. I can get the Workflow instance "Start comment" using, ${instance.data.startComment}

Its the comment that actually gets entered into the participant step when the workflow user actions their inbox. I think I can get the step ID using, ${item.id}

That give me something like VolatileWorkItem_node9_etc_workflow_instances_2015-06-10_model_49688341059757941

I believe the comment is placed under [workflowinstance]/workitem/metadata.comment , as it is there on the archived step under the history node, but I don't seem to be able to get this property.

It may be that this data is just not accessible using the email templates.

smacdonald2008
Level 10
October 16, 2015

You may have to write a custom workflow step and use the JCR API to get this node value. 

Level 2
October 16, 2015

If anyone comes up with a solution, I would like to know.  We are going to attempt to do the same!

Level 2
December 1, 2015

In a custom workflow step use this below code to fetch the comments.

 

public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args) throws WorkflowException {
          

   
          

          HistoryItem previousHistoryItem;
              String stepType;

            List<HistoryItem> history = wfsession.getHistory(item.getWorkflow());

            Iterator<HistoryItem> historyIterator =history.iterator();

            while(historyIterator.hasNext()){

                    previousHistoryItem = historyIterator.next();

                    String comments=previousHistoryItem.getComment();

                    //OR

                    String someproperty=previousHistoryItem.getWorkItem().getMetaDataMap().get("comment", String.class);

    }