Forums

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

I am looking for a working smart value for an automation rule to set watcher

Rixta Padeken September 23, 2020

Hi, 

I know it is not possible to find the @ mentioned user in general. I would like to create an automation rule, where in the comments is searched for any accountId (so far it worked) and then set these accountid as watcher. Unfortunately I am not able to find the right smart value or any working smart value except {{comment.author}}. 

My query starts with:

{{comment.body}} contains regex {{assignee.accountid}}

Now I need the "Add watcher" part.

Can anybody help we with this issue?

2 answers

0 votes
Becky Klein August 26, 2021

Is the @mention trigger still in the works?

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.
August 27, 2021

Hi @Becky Klein 

I found these for user and issue mention in the backlog: 

Best regards,
Bill

0 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2020 edited

Hello @Rixta Padeken

Welcome to the Atlassian Community!

Per your description, I understand that you would like to automatically add a user as a watcher when he is @mentioned in a comment on the issue. Is that correct?

Indeed, the Automation for Jira does not have a simple way to configure it, but we have the following feature request open to allow @mention to be selected as a trigger in automation rules:

@mention trigger 

We suggest keeping an eye on that suggestion to receive any updates about that.

For now, the only way you can do this is to use regular expression matching. So you could set up a rule as below:

  • Trigger: Issue commented

  • Compare condition:

    • First value:

      {{comment.body}}
    • Matches

    • Second value:

      .*\[\~.*\].*
  • Action: Manage watchers add users with this smart-value -

    {{comment.body.match(".*\[\~(.*)\].*")}}

Basically. when a comment is added and a user is mentioned, this is inserted into the comment as [~username], so the smart-value above extracts the username via a regular expression match. You can check more details about this in the documentation below:

Automation conditions 

A limitation of this approach is that it will only add one user as the watcher (if multiple users are mentioned in a comment). There's no work-around for this at the moment.

Let us know if you have any questions.

Rixta Padeken October 5, 2020

Hello Petter,

thank you for your fast respond, unfortunatelly it is not working. The picture shows the audit log of the automation rule, after I mentioned somebody in a comment. The user is found but anyhow the watcher cannot be set via accountid? I don't really get it.

Bug.PNG

Like Deleted user likes this
Deleted user November 17, 2020

@Petter Gonçalves it's not working for me either, I have the same issue than @Rixta Padeken .

Can you please provide with a working solution ?

Thanks !

Nicolas

YY Brother
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 3, 2021

yeah, it doesn't work for me either.

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.
September 3, 2021

Hi community!

As often is the case for things not built-in for automation rules, you will need to experiment to learn what is possible.  For example this worked for me after some experimentation:

  • trigger: issue commented
  • action: create a variable, and use text functions and regular expressions to extract the mentioned users account id values.  Let's call the variable varAddWatcher
{{issue.comments.last.body.match("(accountid:.*)]").remove("accountid:")}}
  • condition: advanced compare to check if there were any mentions by checking for a non-empty varAddWatcher
  • action: add watcher using varAddWatcher

This works for one mention in the comment.  If you expect multiple people to be mentioned, the rule would need to be altered to treat varAddWatcher as a list, and branch over it to add watchers.

Kind regards,
Bill

YY Brother
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

it doesn't work 

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.
September 7, 2021

Hi @YY Brother 

Your comments of "it doesn't work" to not provide enough context for the community to offer help.  I suggest that you try:

  • Consider creating your own/new question if you believe that will improve visibility to the question.  Link to other posts if you believe that will help.
  • Explain what problem you are trying to solve
  • Explain what have you tried thus far to solve the problem
  • Add an image of your complete automation rule.  If necessary, add images of the details of the components to make the clear.
  • Add an image of your audit log from the rule execution
  • Explain how the rule does not work as you expect

If that is not possible, please instead consider asking your site admin to submit a ticket to Atlassian support for assistance.  You may do that here if you are using a paid license for Jira: https://support.atlassian.com/contact/#/

YY Brother
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 8, 2021
  • action: create a variable, and use text functions and regular expressions to extract the mentioned users account id values.  Let's call the variable varAddWatcher  

==> there is no such jira automation aciton. I tried to add the code as the watcher and the result had an error like  

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

 

undefined  

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.
September 8, 2021 edited

The Create Variable action only exists in Jira Cloud automation rules.  Are you using Jira Server/Data Center?

https://support.atlassian.com/jira-software-cloud/docs/differences-between-automation-in-jira-server-and-jira-cloud/

If so, you could try performing the comment parsing and test all at once in the advanced compare condition.

I also respectfully suggest you try writing values to the audit log to confirm if your string parsing is returning the values you expect...before trying to change the watcher field.

YY Brother
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2021

It's really a pity that I don't use Cloud. Thanks for your sugggestion anyway.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events