I am looking to create an automation rule which counts all the comments on a story that have a matching expression in them and input the total number into a field in JIRA .Can anybody help me with that?
Hi @Kunal Kumar
For a question like this, context is important for the community to help. Please post the following:
* an image of your complete automation rule in a single image,
* images of any relevant actions / conditions / branches,
* an image of the audit log details showing the rule execution, and
* explain what is not working as expected and why you believe that to be the case.
Until we see those...
Have you tried using a regular expression with the match() function to do this? https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--
With that approach, the number of matches could be counted using the list size function: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.size
Kind regards,
Bill
Hello Bill ,
Unfortunately I cannot post SS of my rule due to org restrictions. However I'll try to explain what I'm doing.
In the automation rule, im having an action block where I'm updating a field with the following expression .
{{comments.body.replace("[\r\n]","").match("(?i).*(evaluate).*").size|0}}
This is giving me the desired result - no of comments with evaluate expression .
However, i wish to implement an additional check where it should only consider comments added by a particular individual along with the matching expression
Can yoh help me figure out how I can achieve that ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries; I completely understand the challenge in some workplaces of posting rule images.
Next, I recommend not using regular expression syntax for flags (e.g. "(?i)") in automation rules as it is not documented if that does / does not work with Atlassian's implementation of regex. That will save time debugging regex.
Instead, try forcing the comment body to a known case before the match, such as with the toLowerCase() function.
Back to your scenario, you could use smart value, list filtering to extract the comments (or an indicator) that match, storing the results with Create Variable, and then evaluate the variable for the results.
For example:
{{#issue.comments}}{{#if(and(equals(author.displayName, "Bill"), body.replaceAll("[\r\n]","").toLowerCase().match("(evaluate)").size.gt(0)
))}}{{body}}~~{{/}}{{/}}
That will iterate over the comments, testing the author and body to filter them, and return the body when matched, with a delimiter of "~~" between records.
Please adjust / test that expression as I just typed it in without testing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.