I have a project I use to track my vehicle maintenance and fuel logs. I'm trying to automate my fuel milage "MPG".
I have 3 custom numeric fields:
issue.customfield_10216 = Current Mileage ie 31,796 miles
issue.customfield_10215 = Previous Mileage ie 31,271 miles
issue.customfield_10213 = Gallons 33.5 gallons of fuel
In something like excel, I'd have a formula: (issue.customfield_10216-issue.customfield_10215)/issue.customfield_10213
which would result in 15.7 MPG.
Looking at documentation, I'm able to get the first part to work by subtracting issue.customfield_10215 from issue.customfield_10216 resulting in 525, but when I try to divide that by issue.customfield_10213 it just sets the field to 525, instead of doing the division, almost like it's ignoring the rest of my formula.
Here's my formula: {{issue.customfield_10216.minus(issue.customfield_10215).divide(issue.customfield_10213)}}
I tried wrapping the first part in () like this, but that just ended up in error:
{{(issue.customfield_10216.minus(issue.customfield_10215)).divide(issue.customfield_10213)}}
Any suggestions on how to write this properly?
Hello @Jeremy Steuhl
First I recommend that you use the Log action in your rule to print to the rule's Audit Log the value of each of those custom fields to ensure the values used in the calculation are what you think they are.
I tried your math using just Log actions to see the results. First I printed the three values. Then I printed just the .minus operation. Then I printed the full math function. Oddly the results ended up in the wrong order in the log file, but the final full match function result was correct.
Thanks. Can post a screen shot(s) of the rule as you set it up? You said you used my formula but when I use it, I don't get the right answer. Also, I'm not familiar with using the log action in a rule. I'm not sure based on the documentation how to enable that. I'm hoping your screenshot(s) will answer that for me. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was using whatever number fields were available so my fields compared to your fields are
Yours | Mine |
issue.customfield_10216 | Story Points |
issue.customfield_10215 | Custom Story Points Number |
issue.customfield_10213 | SK Only Number Field |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much. Adding values to the audit log helped me solve the issue. The problem I was having in my formula was that I transposed a few numbers, so the formula was working, but it wasn't using the right field.
I was using issue.customfield_10213
when the field was actually issue.customfield_10123.
Putting everything in the audit log showed me that and now it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.