Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Create an Array object in automation for Jira

Hi Community,

I need to compare two Select custom fields and provide an output with the distinct values, for example:

FieldA has the values for apps: A, B, C, D

FieldB has the values for apps: C,D, E, F

I need to compare both field selections and give as output the list without duplicates.

This is important because based on the selection, I need to create a sub-task and I want to avoid creating duplicates.

Any idea how can I do it with Automation for Jira?

Thank you.

2 answers

3 votes
Alex Koxaras Community Leader Sep 19, 2022

@Daniel Alonso 

To my knowledge, unfortunately, this is not possible.

Values from field A will be a list.

Values from field B will be a list.

Creating a variable with these two lists, will yield an "array" of arrays, and you can't use the list.distinct smart value to get the unique values from these two field. A while ago I've tried that for another user, but couldn't succeed :( Feel free to try and if you can manage to do it, please update here!

You could do that if you had an app in which you could run groovy, or jira expressions and had built-in listeners (such as scriptrunner, or JMWE).

Hi @Daniel Alonso 

Yes, Alex's answer: sadly there are not AND/OR operators for fields with which to do this.

If you have a limited number of selection options, you could do this with created variables, logical functions and if/else conditions...but that would be a brittle solution for maintenance.  The upper limit is due to the maximum number of components allowed in a rule.  For example...

  • trigger: some trigger for your source issue
  • action: create a variable depending upon the values of found in FieldA and FieldB
    • name: varAppA
    • smart value: {{#if(or(exists(",").match("(myAppAName)")),exists(",").match("(myAppAName)"))))}}myAppAName{{/}}
  • repeat for all of the applications values as variables
  • create the subtasks by either...
    • use if/else conditions to check the apps, or
    • concatenate all of the created variables together with commas between, and split them back apart using an advanced branch

You could also take a chance and build the first variable as one long string for all possible apps, although that sounds even more difficult to maintain.

Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events