Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


am using Automation for JIRA to run a script when the value of a numeric custom field changes and f


I am using Automation for JIRA to run a script when the value of a numeric custom field changes and for this, I am referring to the page and section -

The changed field value is available anywhere smart values are supported using the {{fieldChange}} substitution. Use {{fieldChange.fromString}} and {{fieldChange.toString}} to access display values and {{fieldChange.from}} and {{}} to access raw values (for a select field for example).

{{fieldChange}} only contains the first changed value. If multiple values are changed (e.g. when setting multiple Fix Versions) then you can iterate over these using the {{#changelog.fixVersion}}{{toString}}{{/changelog.fixVersion}} expression.



This does not work for my number field and I keep getting this error-  "

[c.o.scriptrunner.automation.ExecuteScriptIssueActionV2] Script function failed on Automation for Jira rule: Final script for FNBIPL Pillar - Updated, file: <inline script>, error: java.lang.NumberFormatException: For input string: "1.1"
java.lang.NumberFormatException: For input string: "1.1""


I am using the below lines of code-


def originalValue = ruleContext.renderSmartValues("{{fieldChange.from}}")
def currentValue = ruleContext.renderSmartValues("{{}}") 


Can someone advise me on how I can fix this? I even tried {{fieldChange.from}} and 

{{}} but it did not help

1 answer

0 votes
Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 13, 2022

I setup a number field and created an Automation rule to happen when it changed. Using this script:

def fieldChange = ruleContext.renderSmartValues("{{fieldChange}}")
log.debug "Field change: ${fieldChange}"
def originalValue = ruleContext.renderSmartValues("{{fieldChange.from}}")
log.debug "Original value: ${originalValue}"
def currentValue = ruleContext.renderSmartValues("{{}}")
log.debug "Current value: ${currentValue}"

I saw this in my Jira logs when it changed:

DEBUG 2022-08-13 16:59:46,598 [onresolve.scriptrunner.runner.ScriptBindingsManager] Field change: ChangeItemBean{field='Some Num', fieldType='custom', from='null', fromString='1.3', to='null', toString='2000'}
DEBUG 2022-08-13 16:59:46,598 [onresolve.scriptrunner.runner.ScriptBindingsManager] Original value:
DEBUG 2022-08-13 16:59:46,599 [onresolve.scriptrunner.runner.ScriptBindingsManager] Current value:

Based on that, it looks like the change item's from & to fields are null for number fields.

I'm not quite sure how you're getting a NumberFormatException from that code. I can only assume that you're trying to convert the values into numbers somehow. Are you, perhaps, calling a method like toInteger on it? That would throw a NumberFormatException for numbers like 1.1, since 1.1 is a floating point number, not an integer.

If that's what you're trying to do, you could use the toBigDecimal() method. For example:

def originalValue = ruleContext.renderSmartValues("{{fieldChange.fromString}}")
def currentValue = ruleContext.renderSmartValues("{{fieldChange.toString}}")
def sumOfValues = currentValue.toBigDecimal() + originalValue.toBigDecimal()

log.debug "Sum of values: ${sumOfValues}"

Note that I'm using toBigDecimal to mask over some of the inherent silliness of floating point math.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events