Forums

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

How to combine values from various multiple-select fields into the same field on a linked work item

Sara Beyer
Community Champion
April 17, 2025 edited

Original Question:

 

Is it possible to have two multiple-select fields be "combined" into another ticket?
Use case:
  • ABC-1 has Favorite Color field = Red, Blue, Green
  • ABC-2 has Favorite Color field = Green, White
  • ABC-3 "is blocked by" ABC-1 and ABC-2

 

I want ABC-3 to have Favorite Color = Red, Blue, Green, White

 

Currently I'm using this automation, but it doesn't always pull in all the values as it should and I know it's not complete - and that's where I'm stuck.

  1. When value changes for Favorite Color
  2. Issue Type = X
    1. BRANCH
    2. For linked issues Types: Blocks
    3. Then: Edit issue fields: Favorite Color
      1. Add Favorite color from trigger issue

UPDATE with answer:

This automation worked for me. Essentially, trigger is when value changes for Favorite Color on the linked issues (in my case they are Tasks - ABC-1 or ABC-2). Then, find the linked ticket (ABC-3) which I'm calling parent in this automation. Compare the values - make sure you get at least one parent in this search. Create a lookup table to save the id of the parent. Now - the important step is finding all tickets linked to that parent (ABC-3) with the link you use (in this case "is blocked by"). I added an audit step in here. Once you do all that, you need a branch to perform the concatenation to the parent (ABC-3) only. Since you've "saved" the id for the parent, you search for it using JQL, clear the Favorite color field, refetch the data, and then edit that field to concatenate all the values from all issues linked with our specific link. Because there could be multiple linked tickets (ABC-1, ABC-2 in my example), we use the # and the / in the JSON so that it loops and grabs all the values from all the possible linked tickets, and concatenates them.

  1. When value changes for Favorite Color 
  2. Any if statements needed (i.e. Issue Type is one of Task)
  3. Then: Lookup work items
    1. Search for work items using JQL issue IN linkedIssues({{triggerIssue.key]], "Blocks")
  4. If: Compare two values
    1. Checks if: {{lookupIssues.size}} is greater than 0
  5. Then: Create lookup table
    1. Create a lookup table to use in smart values
    2. {{parent}}
      1. Lookup table name: parent
      2. Define table entries
        1. Key: parentKey
        2. Value: {{lookupIssues.key}}
  6. And: Lookup work items
    1. Search for work items using JQL:
    2. issue IN linkedIssues({{parent.get("parentKey")}}, "is blocked by")
  7. (OPTIONAL) And: Add value to the audit log
    1. {{lookupIssues.customField_XXXX.value.flatten.distinct}}
  8. BRANCH
    1. For JQL
      1. id = {{parent.get("parentKey")}}
    2. Then: edit work item fields
      1. Choose field "Favorite Color" and leave blank to clear anything there
    3. And: Re-fetch work item data
    4. And: Edit work item fields (Advanced)
      1. {
        "update": {
        "customfield_XXXX": [
        {{#lookupIssues.customField_XXXX.value.flatten.distinct}}
        {
        "add": { "value": "{{.}}" }
        } {{^last}},{{/}}
        {{/}}
        ]
        }
        }

 

 

2 answers

3 votes
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.
April 17, 2025

Hi @Sara Beyer 

Using a branch will probably not work for this scenario: branches which could be on more than one thing are run in parallel and asynchronously.  The impact for your rule is the multiple updates could collide, intermittently succeeding or failing.

 

A better approach is to perform one single update of the work item...

Use the Lookup Issues action to first gather all of the "source" issues from which you want to merge the values.  Then update using a JSON expression to add the values need.

Let's assume you want to ADD the values, not replace the ones in your ABC-3 work item.  And so the rule could be:

  • trigger: field value changes for Favorite Color
  • action: lookup issues, with JQL to find any work items with the "blocks" links
    • issue IN linkedIssues({{triggerIssue.key}}, "blocks")
  • smart values condition:   check if any linked work items were found
    • first value: {{lookupIssues.size}}
    • condition: greater than
    • second value: 0
  • smart values condition:   check if there are any values to add; use your custom field ID
    • first value: {{lookupIssues.customField_12345.value.flatten.distinct}}
    • condition: does not equal
    • second value: leave as empty
  • action: edit work item
    • use a JSON expression rather than selecting the field from the dropdown list
{
"update": {
"customfield_12345": [
{{#lookupIssues.customField_12345.value.flatten.distinct}}
{
"add": { "value": "{{.}}" }
} {{^last}},{{/}}
{{/}}
]
}
}

 

Please note well: this rule assumes the trigger issue is the one you want to update.  Additional logic to check the link types is needed when you want to handle any updates, such as finding and branching to your ABC-3 work item.

 

Kind regards,
Bill

Sara Beyer
Community Champion
April 23, 2025

Thanks so much, @Bill Sheboy ! Your answer helped me a ton to get to the final answer :)

I wrote out what my final solution was step by step above if you're interested.

Thanks again!

Like • Bill Sheboy likes this
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.
April 23, 2025

One suggested change in your step 5.2 (and beyond) is to not use any variables (table or created) which use the same name as a built-in smart value.  This prevents both people and rule logic being confused by what to use.

I recommend always adding a prefix to make them stand out, such as renaming the table from parent to varParent or tableParent.

0 votes
Darryl Lee
Community Champion
April 17, 2025

Hi @Sara Beyer -

Unfortunately I think it's because Automation runs branches in parallel. So it tries to "add" the Favorite Colors from tickets ABC-1 and ABC-2 at the same time, and that leads to unpredictable results.

Does that sound about right, @Bill Sheboy ?

Darryl Lee
Community Champion
April 17, 2025

Oh, but you probably want a FIX, not just why your rule doesn't work.

Maybe do a Lookup for Linked Issues of Type Block, and THEN you can set ABC-3's Favorite Color to be:

{{lookupIssues."Favorite Color"}}

Or maybe

{{lookupIssues."Favorite Color".join(",")}}

I'd play with that.

Darryl Lee
Community Champion
April 17, 2025

Or you know, just use @Bill Sheboy 's answer up above. Very complete. Nice work Bill!

Like • Sara Beyer likes this
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.
April 17, 2025

Hey, @Darryl Lee -- I must have been typing that up whilst you were mentioning me :^)

 

Darryl Lee
Community Champion
April 17, 2025

Woof. I've been on the Internet for way too long and forget that it really doesn't matter if I get "FIRST!" here.

Suggest an answer

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

Atlassian Community Events