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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Custom jqlfunction with order by


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

1 answer

1 accepted

0 votes
Answer accepted

Jira already has an order by function, so I think I need to start by asking why that is not working for you?



ok :) the big picture is that i need to have a issue filter ordered by components/fixversion/affectsVersion etc size.


currently it is quite easy to get by customfields but i need to achieve it by other funcrion/order method

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"?


as i wrote before

i'm trying to order issues by COMPONTS SIZE or Affected/FixVersion SIZE

What do you mean by component size and affectd/fixversion size?

by size i mean number of objects in field

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


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 (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.

Got it


Thank You for Your time :)

Suggest an answer

Log in or Sign up to answer

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