Hello, I need some help as I am a groovy/beanshell newb!
I am trying to take the highest value of 3 number fields (risk1, risk2, risk3) and multiply that by a fourth number field (probability) to set a 5th value (residual risk rating). Can anyone steer me in the right direction, maybe give some example code? I've looked around on this tag and have not seen anything similiar! Any help would be greatly appreciated.
You can create a Calculated Number Field, and in the description of that field (Field->Edit), type something like:
<!-- @@Formula: if (issue.get("<field4>")==null) return null; Double m = 0; if (issue.get("<field1>") != null && issue.get("<field1>") > m) m = issue.get("<field1>") ; if (issue.get("<field2>") != null && issue.get("<field2>") > m) m = issue.get("<field2>") ; if (issue.get("<field3>") != null && issue.get("<field3>") > m) m = issue.get("<field3>") ; return m * issue.get("<field4>"); -->
where <field1> ... <field4> are the names of the four Number fields. Note that:
1) these fields must be Number fields - not text fields containing a number (otherwise some conversion is required)
2) the sample code above returns null if any of the fields is null - you might want a different strategy, such as ignoring empty fields 1 to 3.
This works great. Thank you so much for this.
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.