cancel
Showing results for 
Search instead for 
Did you mean: 

Emailing workflow comments

ph73nt
Champ in-the-making
Champ in-the-making
Dear listers

I like my workflows to email users at each stage (my company does not have (and will not switch to) email software supporting RSS feeds). I have created a workflow with task-nodes for multiple users and I would like to be able to access their comments at each stage for emailing.

Workflow overview: Start-> Assignee accepts (writes a comment) -> Email generated (including the comment) -> document owner then accepts/rejects and writes a comment -> Email generated (including the comment)->End (simple stuff).

The workflow details page in Share shows the comments from each stage, but I can only seem to email the first comment. In each task transition I have used the code
token.comments.get(0).message
to grab the comment. When I noticed that the comment emailed was always the first comment, I changed some of the instances to read
token.comments.get(1).message
assuming there was an array to access. But whilst this throws no errors, I still get the first comment emailed.

Would anybody be able to tell me how to access a comment made in the task being performed and not just from the first task-node?

Many thanks in advance, Neil
2 REPLIES 2

lucille_arkenst
Champ in-the-making
Champ in-the-making
I've had good success doing it like this… This way, you will get whatever is the "last" comment, wherever you are in the workflow:

var comment = "";
if (token.comments != null && token.comments.size() > 0) {
    comment = token.comments.get(token.comments.size() - 1).message;
}
HTH

ph73nt
Champ in-the-making
Champ in-the-making
Thanks,

that code did the trick. The first couple of times I tried it I didn't get any change. There must have been a problem with my workflow in another respect or with my deployment.

Many thanks again.

Neil