I have a calculated field that divides two numbers. The division works correctly and I'm able to format the number with the decimal places that I need.
The problem is when I try to order the field. It seams that it's ordering as a text and not a number. the out put that i got is 1.0 2.0 2.6 20.0 4.0 ...
The searcher is "Number Searcher" and the output is cast to Double.
Any tips on how to order this as numbers ?
Hi @Pedro Felgueiras ,
I just tried it with a test number calculated field and the ordering was correct when using a filter.
Could you please share your script and a screenshot of your configuration / filter ?
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def f1 = customFieldManager.getCustomFieldObject("customfield_XXXXX")
def f2 = customFieldManager.getCustomFieldObject("customfield_XXXXX")
def f1v = (issue.getCustomFieldValue(f1) ?: 0) as Double
def f2v = (issue.getCustomFieldValue(f2) ?: 0) as Double
Number val = f1v / f2v
return val
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I stand corrected,
I have used a similar script and got the same issue. I tried multiple scripts and return types, re-indexing the project, field searchers... Without success.
Also I have searched in ScriptRunner's documentation without any luck. So I hope someone from Adaptavist can answer this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What template did you use in the scripted field settings? (Not the search, that looks right, but the template in the scripted field settings themselves)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are using "Number Field" as the template
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, well, I can replicate that behaviour:
Still got the text-like sort
To fix it: re-index after changing the searcher!
(I forgot - we did have a bug in SR 5.something that broke number searches for a while, but I tested with Jira 8.20 and SR 6.48, and it all worked. I think we should check versions)
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.