I have a Script Field called Value returning an integer representing the business value of a feature (the field is calculated based on other fields using Groovy). Its template is Number Field, the return type is int.
Unfortunately when using this field for sorting issues the order is lexicographic. What I need is to have proper integer comparisons and ordering.
Any idea about the possible cause?
Thanks,
Sam
The template just governs how it's displayed, not the sort. I'm afraid I have hard-coded it to compare as Strings.
To deal with this I need to give the user the option to "overload" that, but then you're moving away from a "simple scripted field" that is supposed to be easy to use for non-programmers into a nightmare of a UI with options for everything.
I may implement it like this: "if the user has provided an 'int compare'" method in their script, use that, otherwise use the default".
You could also try configuring it with the number searcher, but I don't think that's going to make any difference.
A bug report containing just a summary and a link to this would be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Jamie, here is the bug https://studio.plugins.atlassian.com/browse/GRV-178
Having this interpreted as an int would really be great. One of the other features I would like is to be able to filter my rapidboard based on that value, but of course I can only do it if it is correctly interpreted.
As a workaround for sorting:
if (val("Customer priority") == "[Yes]") result = 100; else result = 5 *(getValue("Demo value") + ...); return result.toString().padLeft(3, '0')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> One of the other features I would like is to be able to filter my rapidboard based on that value
That *will* work if you utilise the number searcher. But then of course you won't be able to use workaround for sorting that you have.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am still facing this problem.
In both custom field edit and scripted field screens we've selected Number field and re-indexed several times. No joy.
I'm attaching screenshots. Thanks for the help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this still a thing in 2017?
I have a number field template scripted Field in ScriptRunner 5.0.4. / JIRA 7.x for 'days since last update', and can't get it to sort properly :(
It would make solely numeric fields more or less useless if they cant be sorted properly or jql'ed by range?! For e.g. 71 is between 761 and 758.
Sadly I couldn't find any workaround for this. Am I missing some configuration or some other thing here? Or is this simply not possible at the moment because of hardcoded lexicographic sort?
Greets!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey slothstronaut,
I am not sure if you ever figured this out, but I just ran into this exact issue. I was having trouble getting my scripted fields to search by their numeric value. All you need to do is:
This should allow JIRA to sort the numbers based on their numeric values. It worked for me. See attached image.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! I must have overlooked the Searcher Option.
By first looks, I think this solved my Issue!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.