Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I'm trying to send an email to my admins when issues are deleted for backup.
Everything seems strait-forward using the Listener creation screen until I get to the part where I need to include all fields into the email.
I found this helpful post to include all comments: https://community.atlassian.com/t5/Jira-questions/How-to-send-all-Issue-comments-via-custom-Email-using-script/qaq-p/1193521
Any recommendations without listing every single field in the Email Template?
I don't have an issue with listing specific fields, but I'm hoping there is a way to include all system & custom fields without having to list all 700+ custom fields we have in our environment.
I would love to have someone at Adaptavist give me their opinion on how to solve this.
Hi @Chase Brown
Thank you for opening a support request through Adaptavist support channel.
Here you can see the Email template that achieved your need.
Description: ${issue.description} </p></p> Custom Field: <% com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjects().each { customField -> out << "Name: " + customField.getName() + " - Value: " + (customField.getValue(issue) ? customField.getValue(issue) : "No value") + "</p>" } %> </p></p> Comments: <% com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).each { comment -> out << comment.getBody() + "</p>" } %>
Many Thanks and Kind Regards,
Jose Marques
Adaptavist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chase Brown ,
Here's the code to list all the Custom Fields that are available for the specific Issue, it does not make sense to include those CustomFields that are not available to the issue because it will just be a bunch of NULL values.
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
def issue = event.issue
def customFields = ComponentAccessor.getCustomFieldManager().getCustomFieldObjects()
customFields.each{
log.debug("CustomField:" + it.name + "\tValue:" + (it.getValue(issue) ? it.getValue(issue) : '') )
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @brbojorque, Thank you for your quick response.
I think we're on track, but as I'm trying to generate an email, I've go to do this using the GStringTemplateEngine. Here's were I'm at so far:
<%
def issueService = com.atlassian.jira.component.ComponentAccessor.getIssueService()
def customFields = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjects()
def issue = event.issue
out <<
customFields.each{
log.debug(("CustomField:" + it.name + "\tValue:" + (it.getValue(issue)) ? it.getValue(issue) : 'No Value Provided') )
}
%>
This seems to pull all the custom field names, but not the values.
I was trying to toy around with including a validation if the field has values, with an if-else, but I haven't made much progress.
I'd also like to see if I can list them vertically instead horizontally if possible.
Thanks again for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Chase Brown ,
You declared the syntax wrong.
Here's the correct email template, put the out << in the each item in the loop not outside and your ternary operator is not properly enclosed with parenthesis.
<%
def issueService = com.atlassian.jira.component.ComponentAccessor.getIssueService()
def customFields = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjects()
def issue = event.issue
customFields.each{
out << "CustomField: " + it.name + "\tValue: " + (it.getValue(issue) ? it.getValue(issue) : 'No Value Provided')
out << "<br/>"
}
%>
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.