Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

a gotcha to note when using the results of split values, lists, branching, lookups, etc.

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.
February 27, 2024

Greetings community!

While helping with a community question recently, I was reminded about attention to details and rule writing...particularly when using branching and the great new feature of Lookup Tables.

The scenario was:

When multiple users are mentioned in a comment, send them a Slack message to ensure they see it (in case they are not following the email notifications from Jira).

One solution approach has some fairly common elements, such as:

  1. triggering on comment changes
  2. extracting multiple account ID values from a comment
  3. iterating over the values to send Slack messages
  4. translating account ID values to a Slack ID
  5. sending the messages


Item #2 is often solved with a smart value expression like this:

{{issue.comment.last.body.split(" ").match("\[~accountid:(.*)\]").distinct}}

This produces a unique list account ID values, while handling any formatting like line breaks in the comment that may not work with the match.


For item #4, we can use the new Lookup Table feature to map account ID values to Slack ID values.  (For sites with more users, one may instead have user entity properties to identify each user's Slack ID.  That technique is beyond the scope of this discussion topic.)  Let's assume that lookup table is named tblAccountIdToSlackId.

Then it should be straightforward to iterate over the users from Item #2, lookup in the table, and send the Slack message.  Great so far!


But...let's say we are creating this rule incrementally, and chose to store that list of account ID values in a created variable.  Let's assume that is named varAccountIdList.  This approach may also help when diagnosing issues with the rule by logging the variable.

Our advanced branch source would use the expression below, with a branch variable named varAccountId.


And inside our branch, we find the Slack ID like this:


Did you catch the mistake yet?  If not, keep reading...


When we test our rule, surprisingly only the first account ID value matches the get() call to send the Slack message, and nothing else processes.  But there were no errors.  That's curious...


The cause is when we saved a list as a created variable, by default it implicitly joined the values with commas and added an extra space to make the values more people-friendly for reading.  Later when the advanced branch source did a split, a leading space is on each item, starting with the second one.  Those spaces are not in the table keys, and so no matches occur.

There are several ways to solve this symptom.  When that variable for varAccountIdList is still needed, we can be explicit about the join, preventing the extra spaces:

{{issue.comment.last.body.split(" ").match("\[~accountid:(.*)\]").distinct.join(",")}}

Thus we are storing a known text value in a text variable, leaving no doubts about how to split it later.  Testing confirms it works as expected.

The other solution for this would be to provide the list directly to the advanced branch.  But when that is not possible, or when the list is needed for other things, ensuring we know source content is key.


This scenario is a good one to remember using both incrementally checking values during rule writing, and to perhaps to only write to the log during testing.  Otherwise one could quickly consume monthly usage limits for diagnosing rule problems.


Happy rule writing!


Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2024

Very helpful experience sharing. Thanks Bill.

For this use case, I may suggest everybody use Slack app- Jira Cloud directly. Then jira notifications will be sent to Slack as just they're sent to  emails.

Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2024

Great information @Bill Sheboy! Thank you so much for this! 

Like Bill Sheboy likes this


Log in or Sign up to comment
AUG Leaders

Atlassian Community Events