Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Service not working correctly Edited



So i have refactored my code since i last posted a question on here to see if i could get it working better my self (i hope anyhow)


I manage to find a log of where this code was executing and crashing.

Below is my code 


import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import java.util.logging.Logger
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.web.bean.PagerFilter

def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.debug("start of code")

jqlSearch = 'updated >= -4w'; // Create the JQL query to perform
theUser = "jira_bot"; // Specify the user that should execute the query if not logged in

SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
UserUtil userUtil = ComponentAccessor.getUserUtil();
User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

// If the user isn't specified, then set it to the default script running user
if (!user) {
user = userUtil.getUserObject(theUser);
// Set the default list of issues to null just to be safe
List<Issue> issues = null;

// Perform the search as a user and return the result so it can be validated.
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch);

log.debug("inside parse if")
def searchResult =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
issues = searchResult.issues.collect {issueManager.getIssueObject(
log.debug("inside loop")
def estField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11401)
def cFieldValue = issues.getCustomFieldValue(estField)
if ( cFieldValue == 0.0) {
def subject = "${issues.key} has no Estimate"
def body = "${issues.key} \n This issue does not have an estimate"
def emailAddr = ""
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()

if (mailServer) {
Email email = new Email(emailAddr);
log.debug("Mail sent")
else {
log.debug("Please make sure that a valid mailServer is configured")
log.error("Invalid JQL: " + jqlSearch);

 Below is my log


2018-06-06 02:05:37,233 https-jsse-nio-443-exec-68 INFO tyler 125x18592x1 oui304 xxxxxxx /secure/admin/ViewServices!default.jspa [c.o.jira.groovy.GroovyService] groovyService.init : input-file=D:\Atlassian\scripts\logerror.groovy
2018-06-06 02:05:37,236 https-jsse-nio-443-exec-68 INFO tyler 125x18592x1 oui304 xxxxxxx /secure/admin/ViewServices!default.jspa [c.o.jira.groovy.GroovyService] groovyService.init : input-file=D:\Atlassian\scripts\IHNE.groovy
2018-06-06 02:10:00,002 Caesium-1-1 INFO anonymous no estimate - send email [c.o.jira.groovy.GroovyService]
2018-06-06 02:10:02,471 Caesium-1-1 DEBUG anonymous no estimate - send email [c.onresolve.jira.groovy] start of code
2018-06-06 02:10:02,489 Caesium-1-1 DEBUG anonymous no estimate - send email [c.onresolve.jira.groovy] inside parse if


There is no logging under "inside parse if" which gives the indication that the service does not like this section

def searchResult =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
issues = searchResult.issues.collect {issueManager.getIssueObject(


I really hope someone is able to help with this issue, it has held be up for a while.


Many thanks


1 answer

Likely, the user you're searching with has no permissions to see issues -- the list of issues is EMPTY, so the loop is never entered, so nothing is logged within the loop.

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

94 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you