How can I build up a concatenated string field in a branch to update a short text field

Rees_ Ian
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.
January 16, 2025

I have a custom field of type Select List (multiple choices) - this is called Program Impact.  Whenever this is updated, I want to update a short text field (called PI Abbr) with a string which is a concatenation of abbreviations for the multiple choices in the Program Impact field.

e.g. If Program Impact is updated and the choices  

"Long textA" and "Long textC" are seldected, the resultant "PI Abbr" field contains

"CodeN, CodeZ". This is based on a lookup table in the rule shown below

 LongtextA  CodeN
 LongtextB  CodeY
 LongtextC  CodeZ
 LongtextD  CodeA

The rule is a single issue rule so the branch executes inline, so I have created a variable 

varAbbrStr outside of the rule and was hoping to update that in the branch but can't work out how to concatenate those values.  Alternatively I would concatenate the new abbreviation in each branch to the {{issue.PI Abbr}} field value but I think that would mean refetching every loop which will impact performance. In the rule, when the value changes for the Program Impact rule, I clear issues 'PI Abbr' field and create an empty variable varAbbrStr.. In the branch, I iterate though each value set in {{issue.Programme Impact}}, lok up its abbreviated equivalent in the lookup table and attempt to build a concatenation of each of the abbreviations lookup that I can use to finally set the "PI Abbr" field. 

I have a workaround which is creating PI Abbr also as a multi-select and I could just set that each time arounf the loop.  I prefer not to do that because then changes to the abbreviations means maintenance in two places, Jira custom field and the automation script

rule.PNG

 

1 answer

1 accepted

1 vote
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.
January 16, 2025

Hi @Rees_ Ian 

Short answer: This scenario requires using an inline, iterator over the multiple-select, option field and a series of chained replace() functions to convert to the code / abbreviation string value.  For example:

{{issue.myMultipleSelectField.value.join(", ").replace("LongtextA", "CodeN").replace("LongtextB", "CodeY")...}}

 

For more information...

You note this:

The rule is a single issue rule so the branch executes inline...

That is not correct.  An issue branch on one-and-only-one issue (e.g., Branch to Current Issue) is executed inline, as if the branch did not exist.  But branches which could-be-on-more-than-one-thing (e.g. branch on linked issues, advanced branch, etc.) are run in parallel and asynchronously.  There is no way to accumulate the value of the text string using a branch. 

There is a long standing, open suggestion to allow configurable parallel / serial execution.  That is currently shown as "in progress" but there is no hint from the Atlassian team what they are planning to implement.  Please watch here to learn more: https://jira.atlassian.com/browse/AUTO-32

 

Additionally, you are trying to use a Lookup Table for the replacement values.  That cannot work with a long-format iterator because the table data is not visible once inside the iterator.  That is, the following will not work:

{{#issue.myMultipleSelectField}}{{varLookupTab.get(value)}}{{^last}}, {{/}}{{/}}

This is another long standing, open defect / suggestion.  My understanding is the Atlassian team has repeatedly tried to address it without success.  Please watch here to learn any progress: https://jira.atlassian.com/browse/AUTO-490

 

This leaves three possible workarounds:

  • Use the chain of replace() functions I described
  • Change the multiple-select, options to include both values, and then parse them when needed.  For example, the first list option would become: "LongtextA - CodeN"
  • Build an external service capable of performing the replacement and call that from the rule using the Send Web Request action

 

Kind regards,
Bill

Rees_ Ian
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.
January 16, 2025

Thanks Bill, I used a chain of replace functions as you suggested and it worked a treat

Like Bill Sheboy likes this
Rees_ Ian
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.
January 16, 2025

I guess the one thing I didn't understand in your answer was the visibility of the Lookup table.  Within the branch the lookup on the lookup table that was defined outside of the branch seemed to work ok.

Also, the branch was on the values of the issues multi-select field, so it couldn't be multiple issues. Is what you are saying is that Advanced Branching branches are always executed in parallel. 

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.
January 16, 2025

Yes, my understanding is the Advanced Branch always executes in parallel as it could be zero-to-many items. 

Recently, I noticed branch parsing getting "smarter" as a JQL branch was previously always run in parallel, and now a JQL branch over one issue is run inline.  For example, key = TEST-123.  That may be a handy trick for some scenarios.

 

What I meant about the Lookup Table visibility was:

  • It is unavailable inside a long-format, iterator over the field (or other lists):
THIS DOES NOT WORK!

{{#issue.myMultipleSelectField}}{{varLookupTab.get(value)}}{{^last}}, {{/}}{{/}}

  • Within the branch the table is visible, but not super helpful as results keep getting thrown out with each pass through the loop

 

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.
January 16, 2025

Hi @Rees_ Ian 

Pondering a bit further, this is the third question for this type of search (with a table) I have seen this week...and I did develop a much more elaborate way to solve it with dynamic list searching about two years ago.  I even wrote an article on it in October 2024: : https://community.atlassian.com/t5/Automation-articles/Automation-concepts-Dynamic-searches-within-a-list/ba-p/2834235

For your scenario, the search technique would be used twice in a row:

  1. create a variable using the keys in the table to build a regular expression search
  2. use that variable with the match() function and inline iteration to search the field values...saving the result as yet another regular expression search
  3. create a variable to "flatten" the table into text, delimited for each row
  4. split the variable from #3 back into a list, use inline iteration and match() again, feeding it the result of #2 as the regular expression
  5. parse the results of #4 to extract just the matching values from the table

If you want to try this, let me know and I will add more details.

Thanks!

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