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 ?
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
@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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
Please let me know if this one helps.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
The last action if for the first options and etc. for the rest
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.