I want to add a comment (always the same string) in a post function - and I want to add it in the same transition, as if it were entered in the "Comment" field in the transition screen, not firing a separate event. In particular, I want the comment to appear in the notification mail (the same notification mail as the rest of the update). Is this possible?
I can add a comment as a separate event, with, for example, JIRA Misc Workflow Extensions or ScriptRunner, but then the users would get a separate mail about the comment (or no mail about the comment at all), and I want the update and the comment to go together. I am thinking ScriptRunner might be able to do what I want, but I haven't found any examples.
(I tried to let the user add a comment in the transition instead, using a screen which doesn't contain any fields. That works nicely when doing the transition on one issue, but when bulk transitioning issues, I do not get to fill in the comment, since the screen doesn't contain any fields. Thus I'd really appreciate any pointers on how to add a comment to the current transition, or be told it's not possible.)
I guess when you mention "add a comment as a separate event" with Script Runner, you're not working in the post function?
I couldn't find any examples on the web at a glance either, but my notes say that this code should work in a post-function
import com.atlassian.jira.ComponentAccessor import com.atlassian.jira.issue.comments.CommentManager ... def CommentManager commentManager = (CommentManager) ComponentAccessor.getCommentManager(); ... def commentToMake = "I see penguins" ... commentManager.create(issue, transientVars.context.caller, commentToMake, false)
It's a little bit old though, for version 5. The main thing in it is the pointer to comentManager which should still do the job.
There's two little caveats:
Thanks! I've been down that road before, but it's good to know it's actually the right road.
However, the issue does get the comment added, no separate event fired - but still, I see no penguins in the notification mail. (The $comments variable is not set, says Velocity; I haven't looked deeper, and don't know if I could.)
Then again, since I don't necessarily need to tell users about anything except the comment (even if it would be nice), I could actually make the whole transition fire an event sending no mail at all, and then let the comment creation send its mail instead. It's not a nice workaround, but it's beginning to look as if that'll have to do.
Thanks again for your time! (And for all the other questions you've answered previously, where all I needed to do was google. )
Ok, there shouldn't be an extra event fired - that's done by a post function after the other post-functions. I thought that should have included the additional comment, it seemed to on v5. Mind you, with script-runner, you can send an additional email anyway, and that can definitely include the comment.
Could you check the order of the post-functions, making sure your comment is before all the "index" and "write stuff", and that the event firing is after it?
I do comment - store - reindex - fire event, in that order, and it seems like the comment is added "on the side" but with the "Issue Commented" event prevented, rather than adding the comment in the whole transition.
I'm currently using JETI for one set of mails sent, and standard notifications for another set, so I don't think it would be a good idea to create mail with Script Runner as well; that'd be a bit too messy. (And it would have to be everything in the same mail, still - additional emails is no problem, but that would be confusing and irritating in this case.)
Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot