How to define assignee and issue url in send email of post function?

I want to sent email notification with customized Subject and Body to assignee after create new issue.

I think this can be done by Email This Issue post finction in Email This Issue add-on or Send a custom email

post function in Script Runner add on. In case of either case, I want to define the actual assignee name and

issue url in email body. How can I define assignee and issue url? Please provide me with the exact sample / code.

 

2 answers

0 votes
Tarun Sapra Community Champion Aug 08, 2016

The issue object is already available in the script runner execution context

issue.getAssigneeUser().getDisplayName()

Should get you the assignee's display name and for the URL you can easily construct that again in code

"https://jira.mydomain.com"+"browse" + issue.getKey()

Since "issue" object is present implicitly thus there is no need to import anything it should just work.

I want to use Email This Issue post function in Email This Issue add-on. How can I define assignee and issue url? in this case?

Never mind anymore. Thank you for your answer.

Tarun Sapra Community Champion Aug 08, 2016

Please accept or upvote an answer. thanks.

Hi Hisamitsu

If you want to use ScriptRunner's send custom email post function, the body should be something like 

<%
def baseUrl = com.atlassian.jira.component.ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
def assignee = issue.assignee?.getDisplayName()
%>
Assignee: $assignee <br>
Issue url: <a href="$baseUrl/browse/<% out << issue.key %>">$issue.key</a> <br>

Also make sure that the post function is after the Creates the issue originally. step

regards,

Thanos

Thank you for your answer.

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

662 views 4 15
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot