Jira Automation using smart values and text fields - count mentions of a word?

Michael Couillard April 27, 2023

We have a field for "testing notes". Inside that field we sometimes list bugs with a static prefix for each. I'd like an automation to count the number of "bug" mentions and save that to another ticket field. This will power reporting to count bugs per ticket, which we can then summarize by project or dev.

There are a good number of text functions today, but none can find/match/count multiple key words inside a single text field: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/

Is there an alternative?

1 answer

1 accepted

0 votes
Answer accepted
Manon Soubies-Camy _Modus Create_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 27, 2023

Hi @Michael Couillard,

Have you considered linking bug tickets instead of listing them manually?

To answer your initial question, here is how you can count the number of "bug" mentions in a custom field:

{{issue.Testing Notes.toLowerCase().match(".*(bug).*").size}}

I added the toLowerCase() function to count Bug, bug, BUG, etc.

Hope this helps!

- Manon

Michael Couillard April 27, 2023

Good point - for this scenario we're talking inside the context of 1 ticket. So during the initial dev/test process of 1 ticket, it can accumulate a number of bugs that get resolved immediately by the dev.

So when the ticket is fully tested, there might be a handful of bugs reported - but now all are resolved.

We'd like to count that 'internal' number of bugs. Not the new bugs that are forked into brand-new tickets (and handled later).

 

As for match and size - that's a great option! I didn't see it available in documentation, but will give it a shot!

Michael Couillard April 27, 2023

Amazing - it worked! I only had to change from "field name" to the underlying id, like "customfield_123".

Thank you!

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 27, 2023

Hi @Michael Couillard 

Yes, and...to the answer provided:

Do you ever expect multiple "bug" references in a single text line of the field?  If so, consider first splitting up the field as the match() function can only find the first entry per text line.  For example:

{{issue.Testing Notes.toLowerCase().split("\n").join(" ").split(" ").match(".*(bug).*").size|0}}

What this does is:

  • first split the field by line breaks,
  • join back together with a space as a delimiter, and 
  • finally split again by any spaces found.

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events