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) %>
Community moderators have prevented the ability to post new answers.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.