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

How to include epic information in custom email (using Script Runner – Script Listeners – Send a Custom Email )?

Will December 9, 2015

I am using the Script Runner – Script Listeners – Send a Custom Email in the Add-ons to generate email notices.  I am working to setup the Email template to include the required information.  I have figured out how to include the issue and include the epic key and name in the email template.  What I would like to do is access other fields from the epic including custom fields.  When I tried to get the epic as an issue object, i.e. epicObject = issueManager.getIssueObject(epicKey), I got a “No such property: issueManager …” error.  Trying to import the class, i.e. import com.atlassian.jira.issue.IssueManager, did not work either.  The import generated an “Unknown type” error.  Is there a way to get at the epic information in the custom email template?  I have included a sample of the template below.

 

Template Sample

$issue.key - $issue.summary - is 'In Progress' and is assigned to $issue.assignee.name.

Issue Status: $issue.status.name

Epic Key: <% out << issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10600")) %>
Epic Name: <% epicCF = customFieldManager.getCustomFieldObject("customfield_10600")
     epicKey = issue.getCustomFieldValue(epicCF)
     epicDisplayName = epicCF.getCustomFieldType().getEpicDisplayName(epicKey)
     out << epicCF.getCustomFieldType().getEpicDisplayName(epicKey) 

%>

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2015

Hi Will,

Try to get the customFieldManager like this:

def customFieldManager = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()

and in the same way the issueManager:

def issueManager = com.atlassian.jira.component.ComponentAccessor.getIssueManager()

so for example the output for the Epic Key and the Epic Name will be

Epic Key: <% 
def customFieldManager = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()
out << issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10600")) %>
Epic Name: <% 
	def customFieldManager = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()
	def epicCF = customFieldManager.getCustomFieldObject("customfield_10600")
    ded epicKey = issue.getCustomFieldValue(epicCF)
    def epicDisplayName = epicCF.getCustomFieldType().getEpicDisplayName(epicKey)
     out << epicCF.getCustomFieldType().getEpicDisplayName(epicKey)
%>

This will solve the import and no such property errors

Also you should declare variables using the def keyword

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2015

It's unfortunate that with this template engine you can't do imports, so the templates get ugly if you want to do more complex things like this. I think I will provide a way where you can set up the key value pairs using proper script, and pass them to the template.

Mathieu de Lafond July 7, 2016

Hello to all,


I'm trying to set a post function in a simple workflow for Epics, that would do a single thing : set the Epic Status field to "closed" when the Epic is transitioned to closed. As only Epics run through this workflow, there's not even need for conditions whatsoever.


I can't find how to change this field ... is it a system field? a custom field? where can I find information? I tried to get some inspiration from what's above but for example getEpicDisplayName doesn't work.


Thanks for your time,
Mathieu 

TAGS
AUG Leaders

Atlassian Community Events