Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,365,417
Community Members
 
Community Events
168
Community Groups

How to add a comment from the email template of 'Send Custom Email'

Back in the good old days of JIRA 6.1.7 and ScriptRunner 2.1.16 we could add a comment to an issue from within the velocity mark up by adding something like

 

<%

def commentText = "Sent email - IR: Recursive DNS Server" + " - new issue " + issue.key + "."
componentManager.getCommentManager()?.create(issue, transientVars.context.caller, commentText, false)

%>

 

at the end.

Now that we are in the present day running JIRA 7.4.4 with ScriptRunner 5.1.4 this no longer works and no email is sent.

I have been beating my head against a wall to try and figure out how to do this.  None of the suggestions found via google or searching the Atlassian communities have worked. Does anyone have any suggestions?

Thank you.

-- Dan Ehrlich

2 answers

Prosím o přidání do skupiny za GARE 3.C

Hey Daniel,

ScriptRunner 2.1.16 ? wow!!

Lot of things changed since then :)

So now there is a Condition and Configuration field. In that field the script that will create a comment to the issue will be something like 

import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.commentManager.create(issue, transientVars.context.caller, "this is a text", false)

// do not forget to return true - because it is also confition field
true

You can also have a look at the relevant section in the documenation Additional Configuration in Emails

regards, Thanos

Well, that did not work for me.  In the Condition and Configuration box I already had

 

issue.issueType.name == 'Future IR Type' &&
cfValues['Threat Type']?.value == 'Suspicious' &&
cfValues['Sent Initial Email']?.value != 'Yes'

 

So I tried changing it to

 

import com.atlassian.jira.component.ComponentAccessor

if (issue.issueType.name == 'Future IR Type' &&
cfValues['Threat Type']?.value == 'Suspicious' &&
cfValues['Sent Initial Email']?.value != 'Yes') {
ComponentAccessor.commentManager.create(issue, transientVars.context.caller, "this is a text", false)
true
} else {
false
}

This gets me a big red X complaining about transientVars being undeclared and cannot find matching method com.atlassian.jira.issue.comments.commentManager#create.

I tried CommentManager.create also with the same result.  

Importing com.atlassian.jira.issue.comments.CommentManager did not help.

This also did not work (same big red X):

import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager()

if (issue.issueType.name == 'Future IR Type' &&
cfValues['Threat Type']?.value == 'Suspicious' &&
cfValues['Sent Initial Email']?.value != 'Yes') {
commentManager.create(issue, transientVars.context.caller, "this is a text", false)
true
} else {
false
}

 

At a total loss.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events