Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,558,864
Community Members
 
Community Events
184
Community Groups

Scriptrunner: How to access raw JQL query in custom JQL aggregate function

Edited

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?

1 answer

0 votes
Joanna Choules
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 02, 2019

Hi Pavel,

com.onresolve.scriptrunner.runner.rest.jira.JqlFunctionsEndpoint#getAggregateResult is a REST endpoint: ScriptRunner includes some front-end Javascript in the Issue Navigator which captures the JQL entry that has been entered in the search box and sends it to that endpoint. Hope this clears things up and gives you some ideas of how to implement similar functionality yourself.

Joanna Choules, Adaptavist Product Support

How I can write aggregate function and capture full JQL? You do not answer question. Is it possible with ScriptRunner?

Joanna Choules
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 03, 2019

Hi Pavel,

As I mentioned in my original answer, the full JQL is captured with Javascript on the front end and passed to a custom endpoint, which - as you observed - is responsible for invoking the AggregateExpression function.

Custom Javascript can be added to the front end using a Web Resource, and ScriptRunner also allows you to set up custom endpoints. There are many Javascript tutorials available online that describe how to get the value from an HTML text box, and how to perform a call to a REST endpoint.

Joanna

Like Hubbitus likes this

Thanks, I'll try to send that value himself from JavaScript. But it will be much more convenient if ScriptRunner will provide possibility just write aggregate wunctions, without handle such mess.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events