Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation to count specific selections in multi select field

Terry Dance
Contributor
May 20, 2024

I have a multi select drop down with let's say 10 selections, and we have an automation that runs based on 5 values in this dropdown of 10.

I have an automation that runs fine if 1 of the 5 is selected, or if all 5 are but, if someone only selects between 2 and 4 of these specific values is where it falls down.

My automation currently uses "{{issue.customfield_12890.size()}}" and then a "contains" check which works for "1" or "all" of the values, but it wont work if someone say selects only 1 of them specific 5 values, then 2 of the non specific ones. The automation will still "count" it as 3 values.

How do I make it only look for these 5 values.

I did try having an automation that would increase a number field by 1 in the background for each of these 5 specific values, but I couldnt get the automation to then perform an action based on the number in that field.

So a solution to either one would be great.

1 answer

0 votes
Jehan Bhathena
Community Champion
May 20, 2024

Hi @Terry Dance 

Can you share a snapshot of the automation you've currently got? And also, I'm not quite sure I understand the output needed for the use case "if someone say selects only 1 of them specific 5 values, then 2 of the non specific ones. The automation will still "count" it as 3 values", what is not working here? Are you make a decision based on the sum total of the selections here? Or is there another If-Else loop that evaluates the later steps?

Terry Dance
Contributor
May 20, 2024

Here is my automation.

auto.png.

Basically imagine we have 10 services.

Services.

A, B, C, D, E, F, G, H, I, J

If someone selects one of "A, B, C, D, E" then the first part of my automation kicks in.

If someone selects all of them, then another part of my automation kicks in which isnt in the picture.

The issue I have is if 2-4 of them are selected, then I want the bottom part of my automation to kick in, which it does. But it will also kick in if someone was to select a number of "F, G, H, I, J".

How do I specify the automation to only "count" the services from "A, B, C, D, E"?

Jehan Bhathena
Community Champion
May 20, 2024

Thanks for the detailed explanation @Terry Dance ,

So If I'm understanding this correctly the second condition is :

  • "{{issue.customfield_12890.size()}}" > 1
  • "{{issue.customfield_12890.size()}}" < 5
  • If CF value CONTAINS "A, B, C, D, E"

Not if this is the scenario, then if anyone does select "F, G, H, I, J" it should not get triggered. Although your prime issue would be the "issue.customfield_12890.size" since that is currently not calculated as per your expectation.

What I would suggest is:

  • Try to add a negative condition to the second condition, i.e. CF should NOT CONTAINS "F, G, H, I, J"
  • Also, the issue.customfield_12890.size() will always count the F, G, H, I, J values too, what you want to do here if create a new Variable and then iterate over it for every value present in the issue.customfield_12890, and increment it by 1 for each time it find the A, B, C, D, E values. This new variable can then be used in your second conditional loop.

 

Terry Dance
Contributor
May 20, 2024

@Jehan Bhathena 

Thanks for the info.

I did try creating a number field and incrementing it for every value from  "A, B, C, D, E", 

auto2.png

But the last but in this picture just wouldnt work.

If only 1 value was counted, and counted correctly. It always fails at this "count field = 1", even though the field is 1 at this point.

 

Jehan Bhathena
Community Champion
May 20, 2024

Try adding a "Re-Fetch Issue Data" AFTER the field has been updated, the automation runs of the values that it receives when it was triggered, since you've update the value mid way you will have to inform the automation of the new value before using it in another loop.

Terry Dance
Contributor
May 21, 2024

I've added a re-fetch after each update to the count field, but it still only updates the count once.

Is this math correct?

{{#=}}{{issue.customfield_15994}}+1{{/}}

Terry Dance
Contributor
May 21, 2024

Ok sorted it.

My automation was

IF

EDIT

REFETCH

 

I've changed it to

IF

REFETCH

EDIT

 

Now it works

Like Jehan Bhathena likes this

Suggest an answer

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

Atlassian Community Events