Hi All,
I'm quite new to Scriptrunner and Groovy and am running into a snag with a custom field.
This field needs to take values from 2 other custom fields called Impact and probability, with dropdown values of (1, 2, 3, 4,) for each and multiply the values (impact * probability).
I have tried scripting it, but my result is not making sense. max result should be 16, I got 102,272,765!
Is anyone able to help me identify where the issue is and give pointers on how to fix it?
Any help is greatly appreciated.
Cheers,
It is because your Impact and Probability fields are not numbers. Their contents are options with names that are numbers, and you can't cast an option to a number because the data in the option is not numeric.
Try
def ImpactFieldAValue = (issue.getCustomFieldValue(Impact).getName() ?: 0) as float
instead. That assumes your options all have plain numbers as their description text though.
Thank you @Nic Brough -Adaptavist-
I got it working! I changed my impact and probability custom fields to number fields,
then I changed the return to state
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sasha Pilote ,
Take a look at your log to see what value you got for log.debug.
Here's a post on an approach to multiply custom field.
-Ben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Benjamin
Thanks for the reply, I tried matching the script to the method shown In the post you shared:
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.