I'm trying to create a custom (Scriptrunner used) jqlfunction in groovy and I need this query to return issues in a precise order.
Is there any way to create it in scriptrunner? It can be new ORDER BY method or whole JQL Function
The issue is that when I create custom JQL FUNCTION which returns query like "id in (xxx, yyy, zzz)" then the result is not displayed exactly the way I've returned it in jqlFunction ;/
PS I'm not interested in creating customfields just to achieve this
Ok, but why? Order by works for components, fix version, affects version and the other system fields. Why do you think you need a new function for this?
I guess you could say I'm asking "what exactly are you trying to order by"? Maybe an example of a sort you cannot do with "order by"?
Ah, ok, that makes sense.
Yes, you could use Scriptrunner to create a JQL function for this sort of thing. They are a bit more complicated for this purpose than a scripted field (a scripted field script could be as short as "return issue.getComponents().size()" ), but should be possible. Get started at https://scriptrunner.adaptavist.com/latest/jira/custom-jql-functions.html
ok lets explain it again :)
The case is i already have my JQLFunction and it gathers issues quite good but the case is that i need to order them in a specific way in issue navigator -> and ONLY THIS PART IS NOT WORKING as expected;/
actual case is that 'm trying to create, WITHOUT CREATING CUSTOMFIELDS, a jql query to order issues by components size desc
I guess I've already checked everything and my jqlFunction is ordering everything correctly but when i open it in jira my results are not ordered the way i'm putting them in script but by jira.id (i guess)
and my question is:
is it possible to have some custom "orderby function" without creating customfield for that?
I'm sorry, I got too focussed on understanding the problem, and then when I had, relating the solution back to the original question.
Your thinking is correct here, you will need to do this with custom fields.
The JQL functions are for searching, they do not apply to ordering. The "order by" clause is not a part of a query, it is just a way to say "you should sort by this field" to any function that the search results are passed into (those functions actually do the sort, the query does not).
The sort is done by the function displaying the results, not by the query. The issue navigator is only coded to take a field from the sort clause
So, the answer is no, you can't "order by function". You have to do it by field.
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