Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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.

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

How to log work and track time in Jira when a person is part of multiple teams

  The manager’s daily activities include a list of challenges to reach high levels of efficiency for their teams. Part of these challenges is related to how to deal with the worklog systems sin...

105 views 2 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you