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.bc.issue.search.SearchService;
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('My_mailbox@gmail.com','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 = searchService.search(user, parseResult.getQuery(), pageFilter)
issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}
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);
email.setSubject(subject);
email.setBody(body);
email.addHeader('Content-Type','text/html')
mailServer.send(email);
} else {
// Problem getting the mail server from JIRA configuration, log this error
}
}
Hi @Alex
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)
Regards
Sam
@Samuel Gatica _ServiceRocket_
Hi! Yes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.