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

Automation to update custom field "Score" based on custom multi-select field "Scoring parameters"

Finn Harsfort
Contributor
August 15, 2022

I have a custom field called Score that should always reflect the scoring of the issue based on some scoring parameters which is kept in another field "Scoring parameters" (multi-select custom field). To keep it simple, lets assume only 3 possible vaules for scoring: 

- Option A (with a weight of 40%)

- Option B (with a weight of 30%)

- Option C (with a weight of 30%)

 

If only Option A of the scoring parameters is selected, the Score should be 40.

If Option A+B is selected, the score should be 70 (40+30)

If all options are seleced the score is 100.

 

How do I setup an automation rule to calculate a new Score value every time the Scoring parameters are changed ?

2 answers

1 accepted

2 votes
Answer accepted
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.
August 15, 2022

Hi @Finn Harsfort 

I believe you can do this with a single math statement and the filtering of smart value lists feature: 

Inside of your math operation, use your field and filter/check for the specific value and multiply by your weight, summing the results.  One tip to help is using a default value of 0 for when a value is absent.

Kind regards,
Bill

Finn Harsfort
Contributor
August 17, 2022

@Bill Sheboy Thanks Bill, but Im afraid I need a bit more guidance. I assume I just keep the first If condition (Scoring paramter has changed) and then 1 single action to update the score field using a math expression. But the math expression is causing me a headache. How do i iterate the scoring paramters and sum up the values conditionally ? Can you share just a bit of this logic to get me started on right track ? 

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.
August 17, 2022

No problem and glad to help!

For your use case with just a few options, there is a simple way to do this with the match() function.  For example:

{{#=}} {{#if(exists(issue.yourCustomFieldNameOrID.match("Option A")))}}40{{/}}
+ {{#if(exists(issue.yourCustomFieldNameOrID.match("Option B")))}}30{{/}}
+ {{#if(exists(issue.yourCustomFieldNameOrID.match("Option C")))}}30{{/}}
{{/}}
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.
August 17, 2022

My mistake; that one does not work!  I'll experiment with it a bit to see what is not working.  Until then, please continue, perhaps using created variables to sum up.

Finn Harsfort
Contributor
August 17, 2022

@Bill Sheboy I also found out the hard way :) I really appreciate your help Bill and hope you find a solution. So thanks a lot so far. I am also trying some alternatives, but still without succes.  

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.
August 18, 2022

Here's one that works, using list iteration and smart value, in-line conditions (filtering) with equals().

The spacing and null-handling (including the leading 0) are key to prevent errors in the math operation.

{{#=}}0{{#issue.customfield_10063}}{{#if(equals(value, "Option A"))}} + 40{{/}}{{#if(equals(value, "Option B"))}} + 30{{/}}{{#if(equals(value, "Option C"))}}+ 30{{/}}{{/}}{{/}}

How this works...

  • a math expression wraps everything, with a minimum of returning a zero (0)
  • inside is a list iterator on the multiple-select field
  • with a condition test on the {{value}} to dynamically add the value, such as " + 40"
  • any values which return false (i.e. null) disappear from the expression

Please let me know if this one helps.

Like # people like this
Finn Harsfort
Contributor
August 19, 2022

@Bill Sheboy This works like a dream.

Thank you so much for your help on this issue !!!

Like Bill Sheboy likes this
0 votes
Dan Tombs
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.
August 15, 2022

Hi @Finn Harsfort

 

One of the easiest way to do this is to create 3 additional number fields and default value is 0. then create an automation that looks for any update to the score parameter field. Have an if else statement that looks for the different values in the field. If score parameter contains X. Then in 'X number field' change value to Y.

 

Then at the end of the automation - outside of the if else statements. add an action to refetch issue data then add an edit issue action to add all of the number fields back together.

If you need some further help let me know :)

 

Dan

Finn Harsfort
Contributor
August 15, 2022

Hi @Dan Tombs 

I understand what you mean, but we have much more than 3 scoring parameters, so that would be a lot of custom fields to add, but perhaps the only way...

I have been playing around with:

- initilly set score to 0 when the Scoring parameters changes

- adding an if statement for each scoring parameter value:

(if option A the increment Score with 40, if B then increment with 30 etc..

This wont work since Score value is not "kept" on.

I also tried to use create a Variable but cant find a way to update this variable and then assign it to Score as the last step.

 

I hope it is possible to do in some way, so I dont have to create all those addition fields, but I can see that would work.  

Dan Tombs
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.
August 15, 2022

Hi @Finn Harsfort

Are you refetching issue data in between the if statements. Screenshot the rule and I can try and help see what you have to get it working.

Dan

Finn Harsfort
Contributor
August 15, 2022

hi @Dan Tombs ,

No I dont refetch issue data but also tried that without succes. But then it wont "remember" the new value for Score assigned in previous steps. I wish there was a way (using a math formula perhaps, to just assign the new value for the "Score" field based on which options are selected in the "Scoring paramters" field. 

Here is a snippet of the automation rule: 

 

Screenshot 2022-08-15 145523.png

 

Screenshot 2022-08-15 145736.png

The last action if for the first options and etc. for the rest

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events