Script Fields - Which search template should I use for this format: "1d 12h"?

I have a scripted field where I'm returning a duration of time. I went with Xh Xd to keep with JQL's formatting. Is there a way to properliy sort this sort of duration? Number, Text, Date Picker Range aren't working. Any ideas?

1 answer

1 accepted

1 vote

I'm afraid the answer is "none of them".  The problem here is that you're representing a number as a string.  Because it's a string, you need a string type searcher, but that doesn't work for searching numerics

The "duration" stuff in JIRA's search and JQL works because it's storing a number in the background and interpreting it into a string for display - in the background, everything is done in numbers, but it talks to the humans in strings.  There is code to do that number <> text translation.

The script runner does not have that functionality (yet.  I seem to remember Jamie mentioned adding it sometime)

I think your best option might be to swap the field to be numeric, and represent hours.  Then you'll be able to search and sort it properly.

Okay. It was using a double to represent days (ex: 1.11) with a number searcher. Guess I'll be sticking with that. Thanks.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

46 views 0 11
Read article

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