Sorting values of Scripted Field in Issue Search Edited

Hi,

I like to sort issues by key with subtasks directly under the parent.

So I tried the solution proposed here: Sort Issue Navigator by parent-children pairs

After creating the scripted field as suggested, the sorting ("ORDER BY 'Parent Issue Key' ASC, key ASC") only works, if the Parent Issue Key has no Search Template specified. However parent issue key "999" comes after "1000". Using "getNumber()" instead of "getKey" (scripted Field template Number) the same problem occurs. Sorting only works if no search template is specified and 999 comes after 1000.

Is there a good possibility to order subtasks directly under the parent, or is there a mistake in defining the scripted field?

Thanks in advance.

Best regards

1 answer

1 accepted

This widget could not be displayed.

You'll likely need to search by id instead of key. Otherwise it compares them as text as explained here.

You can change:

issue.getKey()
parentIssue.getKey()

to: 

issue.id
parentIssue.id

That should then sort them numerically using the query: 

ORDER BY "Parent Issue ID" ASC, id ASC

Your search template will need to be a number field now.

There are a few gotchas when it comes to running JQL searches in scripted fields which is all documented here if you run into inconsistency issues.

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

281 views 5 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you