Hi,
I'm trying to sum a number custom field (column) values of JQL filter via groovy script. After I get the list of issues I have no idea how to sum the column/custom field values of the issues returned. Any ideas will be highly appreciated. This is my code
def issueManager = ComponentAccessor.getIssueManager()
def jqlSearch = /My JQL Filter/
JiraAuthenticationContext authenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class)
def ParseResult parseResult = searchService.parseQuery(authenticationContext.getLoggedInUser(), jqlSearch)
def value = 0
def qtty = 0
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField myCustomField = customFieldManager.getCustomFieldObjectByName("Custom Field Name")
if (parseResult.isValid())
{
try
{
def SearchResults results = searchService.search(authenticationContext.getLoggedInUser(), parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def List<Issue> issues = results.getIssues()
issues.each //I have no idea what to do here
{
value += (double) it.getCustomFieldValue(myCustomField)
qtty = value
}
}
catch (SearchException e)
{
e.printStackTrace()
}
}
else
{
return null
}
it returns
groovy.lang.MissingPropertyException: No such property: myCustomField for class: Script936 at Script936$_run_closure1.doCall(Script936.groovy:48) at Script936.run(Script936.groovy:47)
Any pointers of how to do this will be highly appreciated.