I have two custom Text Field - (Single Line) fields in my project. Each field contains a number.
I am using a Scriptrunner Fast-Track Post Function to transition my workflow when Field Value 1 is larger than or equal to Field Value 2. However, when I cannot determine how to set the Condition of the Fast-Track Post Function to accomplish this.
For example, right now I am trying:
cfValues['Custom Field 1'] >= cfValues['Custom Field 2']
The script above results in the following message:
Cannot find matching method java.lang.Object#compareTo(T).
When I ignore the static type checking message, I can get the Fast-Track to work. But it is not working correctly--based on the logic in the script above. Does anyone have another way to approach this?
The comparisons will only work when the objects in the field support it. I know you've got numbers in your fields, but the fields are still string based, so they could be trying to do things like 'is "flibble" > "lister"?', which is obviously not a valid comparison.
The comparators basically only work with numeric-like fields. In your data, while you may have "1, 2, 3, 4, etc", you actually have those numbers as their names. It might be easier to imagine the data actually contains "one, two, three, four, etc", which obviously can't be compared logically by computers.
So, either swap the fields to numeric types that can support comparators, or try to parse the custom field values into numbers before the comparison.
Thanks, Nic. As you said, the field type was the issue. I got the fast-track working correctly now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the following on the Atlassian support site:
GREATER THAN: >
The "
>
" operator is used to search for issues where the value of the specified field is greater than the specified value.Note that the "
>
" operator can only be used with fields that support ordering (e.g. date fields and version fields), and cannot be used with text fields. To see a field's supported operators, check the individual field reference.
I am currently working with text fields and I am curious to know if that is the problem. I am going to switch to number fields to see if this corrects the problem, and I will report back.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gavin, I'm interested in your result when you switched these to number fields. I am about to build a similar function (if value is greater than X, set the value of another field to Y) and I'd love to know before I build it if number fields worked. (They didn't the last time I tried this, but I know that post function had other problems preventing it from working - it was a bad UI anyway.)
Let me know what your results were. Thanks!
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.