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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,641,781
Community Members
 
Community Events
196
Community Groups

How much program code is possible in Automation

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!

3 answers

1 vote
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 21, 2022

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

0 votes
Bill Sheboy
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.
Nov 21, 2022 • edited

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

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 21, 2022

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events