Auto-Add Watchers When Mentioned in the comment problem

Omri Zeman January 6, 2025

Hey I make automation that everytime when you mention some user in the comment he become the watcher also.
But the problem that is worked just when you tag only one user, if I tag multiple users its don't work.
can someone have answer what I need to change in the automation to fix it?
Im attach picture of the automation.
thanks.
(this is the smart value code: 

{{issue.comments.last.body.split(" ").match("(accountid:.*)]").remove("accountid:")}}

Capture 14.PNG

3 answers

2 accepted

0 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.
January 6, 2025

Hi @Omri Zeman 

To add multiple users mentioned as watchers the rule will need to iterate over them with advanced branching.

Please see this earlier post I made on how to do this: https://community.atlassian.com/t5/Automation-questions/Re-Re-Finding-Mentioning-a-User-in-Comment-and-Cust/qaq-p/2368567/comment-id/6895#M6895

Kind regards,
Bill

Omri Zeman January 6, 2025

Is this the correct smart value code for now?
{{issue.comments.last.body.split(" ").match("(accountid:.*)]").remove("accountid:")}}

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.
January 7, 2025

That will work, although there are various ways to perform the matching / parsing.

The key for your question about multiple watchers is the need for the branching.  Please see that linked answer for more details.

Like Omri Zeman likes this
Omri Zeman January 7, 2025

Thank you :)

Like Bill Sheboy likes this
Brandon Moberg
Contributor
February 13, 2025

@Bill Sheboy One thing I've noticed is it's possible for users to be tagged in a comment without spacing between the tags, so the above smart value with split would only work for 

[~accountid:XXXXX] [~accountid:XXXYYYYY]

and not for

[~accountid:XXXXX][~accountid:XXXYYYYY]

Have you run into that and found a more preferred matching/parsing approach on your end?

Like Bill Sheboy likes 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.
February 14, 2025

Hi @Brandon Moberg 

The split() helps to solve some formatting problems, but isn't strictly necessary.  It can help with newlines and markup in the field.

Two alternatives are to remove the split() and try:

  • add the text function before the match() to strip some formatting
  • explicitly replace newlines with replace("\n", " ") before the match()

Kind regards,
Bill

Like Brandon Moberg likes this
Brandon Moberg
Contributor
February 14, 2025

Thank you, Bill! I ended up going with this solution, which seems to be working for all my different tests. It will extract any account IDs mentioned in the comment regardless of how they're spaced or not:

{{issue.comments.last.body.match("\[~accountid:(.+?)\]")}}

Fingers crossed I don't run into any edge cases!

0 votes
Answer accepted
Duc Thang TRAN
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.
January 6, 2025

Hello @Omri Zeman 

Seem the smart value of your automation is correct. -> KB link https://community.atlassian.com/t5/Jira-articles/Auto-Add-Watchers-When-User-Is-Mentioned/ba-p/2556829
Can you share the log automation ?

Best,

Omri Zeman January 6, 2025

Hey did you mean to that?

Capture 15.PNG

Duc Thang TRAN
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.
January 6, 2025

Hello @Omri Zeman 

Based on your screen, the smart value doesn’t seem to match the condition.

That’s why the automation isn’t adding the ID of the tagged person as a watcher.

Can you check if some logs have successfully recorded actions?
If all logs didn’t meet the condition, maybe you can try adding a "log action" with the same smart value just before the condition to verify what the value is.

 

0 votes
Vitalii_Bobak_SaaSJet
Atlassian Partner
January 9, 2025

Hi @Omri Zeman,

Alternatively, if you’re regularly working with mentions and need a more streamlined way to manage them, have you checked out the Mentions Dashboard for Jira? It’s a gadget that helps you track and manage all mentions in Jira comments. This could complement your automation by giving you a centralized view of all mentions across tasks, ensuring nothing gets overlooked.

With the Mentions Dashboard, you'll be able to:

  • Easily see all tasks where you or your team are mentioned.
  • Identify mentions that still need attention or action.
  • Ensure smooth collaboration by not missing any critical mentions.                           

image.png

Add-on newly released and developed by my team. 

Best of luck with your automation!

Suggest an answer

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

Atlassian Community Events