how to prevent post function from sending extra email

JIRA - 6.3.1

Script Runner plugin - 3.0.7

I've got a Scripted Post Function that adds a Comment to the issue as it is Resolved. This works fine but it causes multiple emails, one for the Comment (as an update) and then the Resolution of the issue.

Is there anyway to have the Comment added as part of the Resolution transition?

I based my script off of an example from the Script Runner page and I only modified adding the Reporter to the comment content.  Here is the code:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category

 
String currentUser=((WorkflowContext)transientVars.get("context")).getCaller(); 
String reporterUser = issue.getReporter().getDisplayName() 
commmgr=(CommentManager)ComponentManager.getComponentInstanceOfType(CommentManager.class) 
commmgr.create(issue, currentUser, reporterUser +", this issue has been resolved. Please verify work is completed and then CLOSE the issue.", true)
issue.store()

 

This works as I said but it just sends that extra email.

 

Thanks,

Jon 

 

1 answer

1 accepted

1 vote

Pass "false" instead of "true" in the last argument of "create" method.

commmgr.create(issue, currentUser, reporterUser +", this issue has been resolved. Please verify work is completed and then CLOSE the issue.", false)

The last argument determines whether to raise an event for the new comment or not.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

139 views 1 17
Join discussion

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you