If we get as example com.onresolve.jira.groovy.jql.AggregateExpression, it has method com.onresolve.jira.groovy.jql.AggregateExpression#getAggregateData but that call happened only from com.onresolve.scriptrunner.runner.rest.jira.JqlFunctionsEndpoint#getAggregateResult which source is not available unfortunately. And according to jqlQueryDoc.js endpoint /rest/scriptrunner-jira/latest/jqlfunctions/aggregateResult is hardcoded.
In my own function in implementation of com.onresolve.jira.groovy.jql.JqlFunction#validate method I have access only to TerminalClause instance which have no access to full JQL query.
I have abbility implement com.onresolve.jira.groovy.jql.JqlQueryFunction#getQuery, but there I can't emmit some validation errors or warnings about query parsing.
My intention write my custom aggregate query with grouping (question related to https://community.atlassian.com/t5/Marketplace-Apps-questions/ScriptRunner-How-to-custom-extend-aggregate-JQL-function/qaq-p/757436) and I want:
1. Got full JQL query. Current possible approach make it just as string argument of function, but it is not so flexible for user to write it without suggestion and autocomplete.
2. Have possibility return additional aggregation results and/or parsing errors.
2.1. Agregation results required to return additional table data if query correct. I want make summaries grouped by assignee for example.
2.2. If query incorrect on terms of function I want also notify user about it.
On first look it seams I need at least method validate which holds full query like:
MessageSet validate(ApplicationUser user, FunctionOperand operand, TerminalClause terminalClause, String rawQuery)
Is it possible now?
Hello Sergio.
Your code looks alright, you are going to have to look at the JIRA logs for this.
Beforehand, put this in your script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Nombre BR").toString()
log.debug("THE FIELD HAS THIS VALUE: {$cf1}")
def user = ComponentAccessor.getUserManager().getUserByName(cf1)
log.debug("THE USER WOULD BE {$user}")
issue.setAssignee(user)
With this, you will see those lines within your JIRA log, and you will be able to see wether your variables are right or not.
Maybe you will already see something in your logs like an null exception or something like that because the username is incorrect. Not sure.
Regarding debugging postfunctions, you could try them for a particular issue in your script console, in this article you will find an answer by Jamie Echlin, the creator of Scriptrunner describing how to do some debugging.
I hope you found this useful, good luck debugging!
Cheers!
DYelamos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.