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
Next: Root
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
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
Before I explain what I would like to achieve, here my question:
Is it possible to compute a field value in Jira automation to an extend I have in the following Groovy script?
I want to use Jira automation to calculate a value for a field, depending on two other fields which should be multiplied (Since the base fields hold the labels I first need to get the values scores)
Unfortunately the app, in which I need the value, does not support calculated custom fields. If the user edits the issue, updating any one of my to base fields I want to recalculate the depending field and set its value.
In the calucated field, if I could use it, I would use a Groovy script as follows to set the calculated field:
def significance = [Negligible:1, Moderate: 2, Significant: 3, Extensive:4, Catstrophic:5]
def probability = [Theoretical:1, Unlikely: 2, Possible: 3, Likely:4, Frequent:5]
Integer s = 0
Integer p = 0
//Evaluating the expression value
switch(issue.get("customfield_13418")) {
case "Negligible":
s = significance["Negligible"]
break
case "Moderate":
s = significance["Moderate"]
break
case "Significant":
s = significance["Significant"]
break
case "Extensive":
s = significance["Extensive"]
break
case "Catstrophic":
s = significance["Catstrophic"]
break
default:
s = 0
break;
}
switch(issue.get("customfield_13410")) {
case "Theoretical":
p = probability["Theoretical"]
break
case "Unlikely":
p = probability["Unlikely"]
break
case "Possible":
p = probability["Possible"]
break
case "Likely":
p = probability["Likely"]
break
case "Catstrophic":
p = probability["Frequent"]
break
default:
p = 0
break;
}
// return the value
s*p
Thanks for any idea!
The out-of-the-box actions in Automation for Jira can't run Groovy scripts, but we developed an app called Better DevOps Automation which can.
This app has a general-purpose "Run Groovy" automation action which you can add to any automation rule, not just devops-minded ones.
For more information, see: https://midori-global.com/products/better-devops-automation-for-jira/server/documentation/automation-actions#run-groovy-script-action
Hi!
Please see the other answers regarding calling other code from a rule.
For your use case, I believe you can do this with the Jira Server version of Automation using a single statement, with conditions nested inside of a math operation.
For example:
{{#=}}( 0 + {{#if(equals(issue.significance.value, "Negligible"))}}1{{/}}{{#if(equals(issue.significance.value, "Moderate"))}}2{{/}}{{#if(equals(issue.significance.value, "Significant"))}}3{{/}}{{#if(equals(issue.significance.value, "Extensive"))}}4{{/}}{{#if(equals(issue.significance.value, "Catstrophic"))}}5{{/}} ) *( 0 + {{#if(equals(issue.probability.value, "Theoretical"))}}1{{/}} {{#if(equals(issue.probability.value, "Unlikely"))}}2{{/}} {{#if(equals(issue.probability.value, "Possible"))}}3{{/}} {{#if(equals(issue.probability.value, "Likely"))}}4{{/}} {{#if(equals(issue.probability.value, "Frequent"))}}5{{/}} ){{/}}
Please check your actual selection field values, as I copied from your posted question.
To learn more, please look at these references:
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ML
Maybe you can do it without groovy script by doing an if then else for each combinaison.
One other solution would be to store significance and probability in issue properties then calculate s*p
Regards
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.