Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Why is JQL result not coming?

Hi Community โ€“ I have a question for all you experts ๐Ÿ˜Š

with jql you need to get such a result, but I have problems with this


import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.mail.Email;
issueManager = ComponentAccessor.getIssueManager();

customFieldManager = ComponentAccessor.getCustomFieldManager();
regprov_sla = customFieldManager.getCustomFieldObjectByName("SLA_US_Reaction");

// Body

results = '<html><body><h3>Report</h3><br>'
results += '<b> Report project : REGPROV</b>.<br />'
results += '<table><tr><th>Assignee</th><th>Average task completion time</th><th>Amount ticket</th></tr>'

jql = 'project = REGPROV AND status = Closed AND resolved >= startOfWeek() AND assignee in (a.emelyanenko,e.povaga)'

issues = getIssues(jql)
results += '</table><br /><br /><br />'
today = new Date().toTimestamp()
results +='<br /><small>\DATE REPORT: '+today+'</small>'
results += '</body></html>'

sendEmail('','REPORT', results)
return results 

def getIssues(jql)
    resultIssues = []
int start = 0
    int get = 100
    searchService = ComponentAccessor.getComponent(SearchService.class)
    user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
    issueManager = ComponentAccessor.getIssueManager()
    parseResult =  searchService.parseQuery(user, jql)
    exist = true
    while (exist)
        pageFilter = new PagerFilter(start, get)
        searchResult =, parseResult.getQuery(), pageFilter)
        issues = searchResult.results.collect {issueManager.getIssueObject(}
        if (!issues) { exist = false }
        resultIssues += issues;
        start += get;
        println "TEST recieved " + resultIssues.size() + " issues for $jql"
    return resultIssues

def sendEmail(emailAddr, subject, body) {
mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();
if (mailServer) {
Email email = new Email(emailAddr);
} else {
// Problem getting the mail server from JIRA configuration, log this error


1 answer

Hi @Oliver Smith 


Have you confirmed you get any data from the UI using the same JQL?

project = REGPROV AND status = Closed AND resolved >= startOfWeek() AND assignee in (a.emelyanenko,e.povaga)




Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

An unofficial way to monitor a JSM mail handler for errors

...eturns true if any content is returned for the s...

682 views 3 20
Read article

Atlassian Community Events