You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
We have a requirement to have a scripted field automatically calculate % value in real time, based on Actual and Target number fields.
We have scriptrunner installed, so we have to use that tool.
If anyone has a sample Groovy code for that it will be greatly appreciated!
1. CF  - Target number
2. CF  - Actual number
3. Scripted field = CF/CF - always displayed and updates in real time if CF chnaged.
Hi @Alex Kulichkov ,
please try something like this (just replace the constants with your custom field ids):
Long CUSTOM_FIELD_ID_1 = 10359L
Long CUSTOM_FIELD_ID_2 = 10400L
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customField1 = customFieldManager.getCustomFieldObject(CUSTOM_FIELD_ID_1)
CustomField customField2 = customFieldManager.getCustomFieldObject(CUSTOM_FIELD_ID_2)
Float number1 = issue.getCustomFieldValue(customField1) as Float
Float number2 = issue.getCustomFieldValue(customField2) as Float
return (number1 && number2) ? number2 / number1 * 100 : 0