I have a multy-choice dropdown with a few options. Each option has own weight (1, 2, 3 etc)
Depends on the choice I need to calculate the sum and show it in another field
Hi @Mykhailo Goncharov -- Welcome to the Atlassian Community!
Without seeing your complete rule or calculation for context...
You could try using a list iterator, with conditional logic, wrapped in a math expression. For example, assuming a default value of 0 is okay for the sum:
{{#=}}
0
{{#issue.customfield_2345.value}}
{{#if(equals("Option A"))}} + 1 {{/}}
{{#if(equals("Option B"))}} + 10 {{/}}
{{#if(equals("Option C"))}} + 100 {{/}}
{{/}}
{{/}}
How this works:
Unfortunately, a Lookup Table cannot be used to perform this translation / summation because once inside of the field iterator, no other data is visible / accessible.
Kind regards,
Bill
I would probably agree with @Tobias H here that the best bet (for now) would be IF/ELSE conditions.
However, you might want to follow this suggestion - AUTO-32. If by implementing this suggestion it would be possible branch on values sequentially (and not in parallel as it is at the moment), you could probably construct something like this:
Basically, with Lookup table you would map each option in the multi-select field with 'weight' for each option.
Next, you could iterate through each value in the multi-select field and get each value weight from the table you defined previously. Lastly, you would use a math expression in the number field to sum up all weights into that one field.
E.g., in the number field you can have an expression like this:
{{triggerIssue.customfield_10486}} + {{weightMapping.get(item).asNumber}}
Again, note that I didn't manage to get it to work, as branches just run concurrently and they execute too fast (even w. re-fetch or delay actions).
If Atlassian releases sequential iteration in the branches, I think this would be a 'cleaner way to go' compared to IF/ELSE blocks.
Cheers,
Tom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or, you might just ask an expert on automation - @Bill Sheboy to see if there are any tricks regarding this topic 😄
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mykhailo Goncharov and welcome to the community!
Based on the limited info you provided, I'd suggest an automation like this:
Create IF/Else component and then do
If Multi-Choice Equals 1
Then Edit Issue
Advanced options:
{
"update": {
"customfield_11380": [{
"set": "{{#=}}{{issue.customfield_11380}} + 100{{/}}"
}]
}
}
And then just do that for all selected and add different weights instead of the "100" in my code above, and swap out the customfield for what your own field is called / id of the field.
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.