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.

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

ScriptRunner Script Listener "Send a custom email" Sends Empty Mails

Mayorov Alexander August 20, 2018

Hello!

I'm trying to setup "Send a custom email" with Email template shown below. Preview works fine, and shows list of issues. Emails coming. But they are empty.

Did anyone have this problem? Tank you for any help!

ScriptRunner v3.1.4 / Jira v6.4.7

 

<%  
def cfFixVersions = issue.getFixVersions()//array of Strings
def issueVersiiArrayOfStrings = cfFixVersions.collect{'"' + it + '"'}
def issueVersii = issueVersiiArrayOfStrings.toString()
issueVersii = issueVersii.substring(1, issueVersii.length() - 1)
 
def String jqlQuery = "fixVersion in (" + issueVersii + ")"

def user = com.atlassian.jira.component.ComponentAccessor.getJiraAuthenticationContext().getUser()

def jqlQueryParser = com.atlassian.jira.component.ComponentAccessor.getComponent(com.atlassian.jira.jql.parser.JqlQueryParser)
def searchProvider = com.atlassian.jira.component.ComponentAccessor.getComponent(com.atlassian.jira.issue.search.SearchProvider)
def query = jqlQueryParser.parseQuery(jqlQuery)
def jqlresults = searchProvider.search(query, user, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())

def issueTypes = [:].withDefault {[]}
def jqlIssues = jqlresults.getIssues()

for (issueItem in jqlIssues) {
 
    def issueTypeObjectName = issueItem.getIssueTypeObject().getName()
    issueTypes[issueTypeObjectName].add(issueItem)
 
}//end for (issueItem in jqlIssues)

def String strResult = ""

for (issueType in issueTypes){
 
    if (issueType.value.size() > 0){
 
        strResult = strResult + issueType.key + '\n'
 
        for (issueItem in issueType.value){
 
            strResult = strResult + issueItem.getKey() + " " + "[" + issueItem.status.name + "]" + " " + issueItem.summary + '\n'

        }//end for
 
    }//end if (issueType.value.size() > 0

}//end for (issueType in issueTypes)

out << strResult
%>

 

1 answer

0 votes
Jenna Davis
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.
August 27, 2018

Hello, 

I think that this may be an old bug effecting the version of SR that you're using.

Check out this community post and this bug report from that explain the issue a bit more. 

Let me know if you have any further questions.

Regards, 

Jenna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events