Trying to send a custom email to reporter upon Issue creation (issue created within Service Desk) which includes some details about the values they entered for various fields (including custom fields) within the Body of the email... (see example of what I am effectively wanting to do below)... So trying to do this via a script that would fire on issue creation, (with ScriptRunner)...
so wondering if there is a trick to this simply or do I have to look at the GStringTemplateEngine... that is suggested on that config page...
and if so...
curious how I get to my specific JIRA fields "standard" and custom fields. like issue, description, (some custom field...)
appreciate any real life example for JIRA that I can use...
(that GStringTemplateEngine wiki doesn't help me to know how to get at JIRA field...)
Appreciate any suggestions.
I think the example below covers a couple of cases (issue fields, subtasks, custom fields). Hope is enough for a start, if you want something that is not covered from the example, comment and I can assist further (I suppose you already know how to set up a listener, and your question was mainly for the email body).
<% def issueTypeName = issue.issueType?.name def issuePriority = issue.priority?.name def subTaskList = issue.getSubTaskObjects() def firstSubTask = subTaskList ? subTaskList : null def subTaskId = firstSubTask?.getId() def subtaskPriority = firstSubTask?.priority?.name def subTaskType = firstSubTask?.issueType?.name def subTaskCustomField = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName ("A custom field name") def customFieldValue = firstSubTask?.getCustomFieldValue(subTaskCustomField) %> Issue Name: $issue <br> Issue typeName: $issueTypeName <br> Issue priority: $issuePriority <br> Subtask Name: $firstSubTask <br> SubtaskId: $subTaskId <br> Subtask Priority: $subtaskPriority <br> Subtask Issue type: $subTaskType <br> Subtask url: <a href="$baseUrl/browse/<% out << firstSubTask?.key %>">$firstSubTask</a> <br> $subTaskCustomField (customField): $customFieldValue
thank you for the advice. Well it is my first "attempt" so I'm falling over simple steps I fear,
So in trying to create an easy "listener", - send a custom email,
I put just these 2 lines in the email template portion of that "listener"
def CustomFieldSelectedAreas = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Selected Areas")
def SelectedAreas = issue.getCustomFieldValue(CustomFieldSelectedAreas)
but get this type error
No such property: componentManager for class: groovy.lang.Binding
For the first error you get, you use somewhere the componentManager which in JIRA version 7 onwards became deprecated. Use componentAccessor instead (in the way you did in the lines you pasted).
For your second question. In a custom listener the only think that is bind is the event. Therefore in order to get the issue you should
def myIssue = event.issue
It started as any story starts, on a normal, rainy day. Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...
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!
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