Forums

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

Automation to include smart values and match function

Rosalind Barker May 14, 2025

Hi Everyone

I am trying to create an automation using smart values (a custom lable field). I would like an automation to return any matches from a set list. For example:

I have a custom label field (eg "Horses") which can contain a varying number of labels (eg buttons, apples, red_rum). 

I would like a formula which reads all the labels added to the custom field, compares them to a list of horses that can showjump and returns the matches in the description (or another custom field). eg, my list will have apples, but not the other two horses, and the automation will add something like this to the description of the ticket:

"Apples" can showjump

"buttons, red_rum" cannot showjump

 

I tried co-pilot, and it wasn't helpful.

 

 

 

 

 

1 answer

1 vote
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.
May 14, 2025

Hi @Rosalind Barker -- Welcome to the Atlassian Community!

Short answer: the "trick" is to store your regular expression in a variable and then use that variable in the match() call.

 

For more information...

There can be timing and evaluation order problems with the match function, leading it to parse incorrectly.  And so storing the expression in the variable fully evaluates that before use.

For example, if we wanted to search for an exact match to the Summary in one issue to the results of a lookup issues action, we could:

  • action: create variable
    • name: varRegEx
    • value: .*({{issue.summary}}).*
  • action: lookup issues to gather other issues...
  • action: something needing the match result
    • {{lookupIssues.description.match(varRegEx)}}

 

Please note well:

  • There are no surrounding quotation marks in the variable for the regular expression
  • And, if the smart values used to build the regular expression could contain reserved tokens (or characters requiring escaping), extra steps and variables are needed to escape them first

To read about more complex uses of this technique, please see this article I wrote on dynamically searching list values: https://community.atlassian.com/forums/Automation-articles/Automation-concepts-Dynamic-searches-within-a-list/ba-p/2834235

 

Kind regards,
Bill

Rosalind Barker May 14, 2025

Hello Bill

Thank you so much for your prompt answer to my question.

I'm quite new to this, so I'm afraid that I don't understand your response (so sorry). Should I create a lookup table? That only contains 200 entries - I will need 800, should I create 4 tables?

Under define table entries I can have a key, and then that returns a value

Do I then use the get function?

 

 

The automation that co-pilot suggested was as follows:

1. When value changes for 

<Generic Field Value> 

Change type: value added

For: All work item operations

2. Edit work item fields (SET option)

Matched Labels:
{{#issue.customfield_12792.split(",")}}
{{#if(equals("alcohol", .))}}
- {{.}}
{{/}}
{{/}}

 

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.
May 14, 2025

First thing: I recommend not using any bot / AI tool to answer automation questions...even the built-in one from Atlassian. 

The reason is each Jira Site has different configuration settings (e.g., Jira version, installed apps, installed products, projects, custom fields, work item types, workflows, etc.) and the bot cannot access those to provide an accurate answer for non-trivial needs.  Indeed, the suggestion the bot provided you has an invalid conditional expression, incorrect use of Edit Work Item, etc.  Such bots also do not have access to the current defects in Jira to provide workarounds.

 

Back to your question, let's get more specific on the scenario... 

Would you please describe: what problem are you trying to solve?  That is, "why do this?"  Knowing that may reveal alternative solutions.  Thanks!

 

Sticking with what you have described thus far, and using your earlier example terminology, the scenario (not the problem to be solved) seems to be:

GIVEN work items have a custom label field named Horses
AND some of the possible values of Horses map to a "showjump" indicator
WHEN a work item's Horses field updates
THEN for a value added to the Horses field which maps to "showjump", search for those added values in the Description field
AND <do something> with the matches found

 

The mapping is the problem as you note 800 values, and that would be very difficult to maintain in an automation rule, regardless of how it is done: multiple lookup tables, or one large created variable representing a list of comma-separated values.

Knowing the problem you are trying to solve will help before suggestion more rule ideas.

Rosalind Barker May 15, 2025

Hi Bill

Thank you once again for replying so promptly.  

GIVEN work items have a custom label field named Horses
AND some of the possible values of Horses map to a "showjump" indicator
WHEN a work item's Horses field updates
THEN for a value added to the Horses field which maps to "showjump", search for those added values in the Description field list those items in the description saying 'showjump ready'

The reason I need to do this (the example above is of course a dummy), is because I have two teams updating the same entries on a database (let's pretend it's a wiki page).

Team A publish routine updates to the wiki pages every month

Team B are going through all the wiki updates systematically and changing the updates to a new format. We want to avoid Team A from doing a routine update to a page and changing the format of the page back to what it was before Team B updated it.

Currently, we need verbal communication and lists to prevent Team A from overwriting the new changes.

I would like a Jira automation to show on a jira ticket that whatever wiki page they are updating is in the new format before they start doing anything.  (there are warnings in the database, but they need to be in JIRA as well).

Sometimes Team A will be updating one wiki page. Sometimes Team A will be working on an update which will update two wiki pages in one go (and I cannot use subitems for this). Eg there might be more information on different breeds of dog and the writer would need to update two separate wiki pages eg 1 poodles and 2 labradoodles. The update to both is exactly the same, and the database will take the same paragraph and pull it into two places. 

Team B has put poodles into the new format. Team has NOT put labradoodles into the new format. I want a clear warning on the jira ticket that shows this. eg:

Poodles - new format

Labradoodles - not new format.

It would be nice to have a third option "Team B working on new format" but that would be a nice to have. The pages that Team B are working on will go into the hundreds, 

Thanks again for your help, it's much appreciated.

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.
May 15, 2025

Thanks for that information, and I understand obscuring some details for the scenario.  As a suggestion, perhaps pause and explain this scenario in a verbal conversation with your Jira Site Admin (or another team member).  In my experience, doing that often reveals new solution approaches...and, you would likely not need to obscure any details :^)

 

Continuing my earlier suggestions...How do you maintain the list of "Horses" which indicate "showjump" and how frequently does it change?  If the answers are "manually" and "often", using an automation rule to solve this may be a risky approach.

If the list is very stable and changed infrequently, you could create a single variable to hold the list, like this:

  • action: create variable
    • name: varJumpingHorses
    • value: buttons, apples, red_rum

Then use another variable to convert that into a regular expression to use in a search:

  • action: create variable
    • name: varRegEx
    • value:
({{varJumpingHorses.split(", ").join("|")}})

That will produce a result like this: (buttons|apples|red_rum)

Finally that expression may be used with the match() function to return any matches in the Description field:

{{issue.description.replace("\n", " ").match(varRegEx).distinct}}

I added the distinct function on the end to remove duplicates, but you can remove that if you want the duplicates.

 

This approach, although cumbersome to maintain the list, will work for up to several million values in varJumpingHorses (based upon my testing a few years ago with the limits of created variables).

Rosalind Barker May 16, 2025

Thank you so much, I will try 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.
May 16, 2025

Oops...there where some typos in my definition of varRegEx.  Please see the updates in the earlier post.

Suggest an answer

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

Atlassian Community Events