Need help with the automation rule

Mykhailo Goncharov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 6, 2024

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

3 answers

3 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.
November 6, 2024

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:

  • iterating over the selected values in the custom field
  • check if it matches an "option", and add the relevant weight.  Note this uses the implied {{.}} parameter from the list to the equals() function.
  • wrapping all of that in a math expression, with a 0 value at the front for a default

 

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

0 votes
Answer accepted
Tomislav Tobijas _Koios_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2024

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:automation-example.png

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

Tomislav Tobijas _Koios_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 6, 2024

Or, you might just ask an expert on automation - @Bill Sheboy to see if there are any tricks regarding this topic 😄

0 votes
Answer accepted
Tobias H
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.
November 6, 2024

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events