Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Jira Automation: Count how many times a specific set of numbers are in a paragraph custom field

Philip Ng
Contributor
March 14, 2025 edited

I am using a Jira Issue for a bug that records the client ids that have reported the issue in a custom paragraph field. If a client reports the issue multiple times, their client id will show up multiple times. 

I am trying to setup an automation where if you manually trigger the automation, it prompts you to enter the client id number you are looking up. Then I want it to count the number of times that user entered client id appears in that paragraph custom field and export that number to another custom field.

I can setup the prompt but when it goes to return the count, there is no calculated response.

This is the automation I setup:

{{issue.customfield_11371.match(userInputs.searchcounter).size}} times

 

2025-03-14_23-20-28.png

 

Example:

Customfield_11371 contains this data:

1234

7499

2468

6654

7499

 

I trigger the automation and enter 7499 but no response but the word "times:" appear I'm looking for it to enter 2 times into the new custom field.2025-03-14_23-19-23.png

 

Can someone assist me in telling me what I am doing wrong? Thank you

 

2 answers

1 accepted

7 votes
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.
March 15, 2025 edited

Hi @Philip Ng 

Your rule is trying the user input field in the match() function but it is not in the correct format for the function's use of regular expressions.  To solve this, first create a variable which wraps the input in parentheses and then uses that variable in the function.

  • trigger: manual input, with the user input, and assuming it is a required field
  • action: create variable
    • name: varRegEx
    • value: ({{userInputs.searchcounter}})
  • action: log, to check the result
    • {{issue.description.replace("\n", " ").split(" ").match(varRegEx).size}} times

 

The match() function does not support adding content from smart values and so this technique allows creating a dynamic regular expression.

 

Kind regards,
Bill

Philip Ng
Contributor
March 15, 2025

Thank you! Now I understand how this works. 

Like Valerie Knapp likes this
Philip Ng
Contributor
March 17, 2025

@Bill Sheboy I just noticed a small issue. If the number I search for only appears once in the array, it doesn't show the number in the search result. It only shows if there are two or more instances of it. Any way to get it to show the number 1 if it only appears once in the list?

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.
March 17, 2025 edited

I expect this is related to newlines and other characters in the text...which cause challenges for the regular expression handling of the match() function.

Let's make it super easy for match() to figure things out:

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

That replaces the newline character with a space and then splits into a list of "words", reducing the scope match() checks to one "word" at a time.

 

I will update my earlier post to match this expression.

Like Philip Ng likes this
Philip Ng
Contributor
March 17, 2025

That worked. Thanks.

Like Bill Sheboy likes this
2 votes
Valerie Knapp
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 14, 2025

Hi @Philip Ng , thanks for your post. 

What is the goal overall? You want to have a report of how many times the customer has logged the bug?

Do you have any apps available to help you with this? Like Jira Misc or ScriptRunner?

To me, this sounds kind of like a use case for a Listener to capture and analyse the data and then to edit a custom field or label to identify, ok, this bug was reported in customerA 12 times, 4 times in another customer, etc. 

Looking forward to your reply. 

Cheers

Philip Ng
Contributor
March 15, 2025

I do not have any apps like those but yes, that is kind of what I am looking for. Is it not possible to do without those apps?

Suggest an answer

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

Upcoming Jira Events