Add watcher automatically based on a custom field

Ani Popova September 15, 2021

I have a custom field 'Evaluators' where the user can select multiple people from the organization. Is it possible to create an automation that would pick up the evaluators from the field and add them as watchers on the issue?

7 answers

3 accepted

6 votes
Answer accepted
Alex Koxaras _Relational_
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 15, 2021

Hi @Ani Popova 

Yes you can! Use the following rule and replace approvers with Evaluators:

approvers.png

Keep in mind that evaluators must have permissions to view the issues.

John Funk
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 15, 2021

Ah! Well done, Alex!

Like # people like this
Ani Popova September 15, 2021

Hmmmmm, that's a very good idea actually, thanks a lot!

Like # people like this
1 vote
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.
September 15, 2021

Hi @Ani Popova 

If you are selecting those evaluators from the Jira users, and you can get the accountId from the selections, then you may add them as watchers with an automation rule.

The trick may be to split out the accountId values from the field, split it into a list, and then use advanced branching to iterate over them to add each watcher.  Another way might be to use advanced edit with JSON to add them all at once.

Kind regards,
Bill

Withdrawing my answer, based upon Darryl's comments.

Ani Popova September 15, 2021

I see what you mean, that's going to take a long branch rule, because probably have about 15-20 people to loop through, but it would work! 

The disadvantage would be that every time a new person gets hired, I will have to change the rule. 

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 15, 2021

Hi, Ani!  This would still be dynamic; the values from the field drive the new advanced branch mechanism which was recently added.  So the branch would just have a few components.

For now, I recommend starting with what Alex suggests based upon the field-value changed trigger.  If you run into challenges with add/remove watchers and duplicate watchers, this other technique could help.

Kind regards,
Bill

Withdrawing my answer, based upon Darryl's comments.

Darryl Lee
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 15, 2021

Whoa whoa whoa! :-}

As much as I love complex branching rules that can iterate over lists, this one can be solved much more easily, because thankfully, Atlassian/CodeBarrel implemented Watchers differently than other fields.

And you can actually add Watchers without affecting existing Watchers (which was my concern with doing any kind of fancy JSON).

Like # people like this
1 vote
Answer accepted
John Funk
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 15, 2021

Hi Ani,

Unfortunately, automation only has the ability to have an actual username selected to add to the watcher field not not groups or values from other fields. 

You might could do it via the API, but that is out of my expertise. 

Darryl Lee
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 15, 2021

Hey @John Funk sorry, but this isn't actually correct:

watchers.jpg

Like Dave Liao likes this
John Funk
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 15, 2021

Yep - noted above

2 votes
Deborah Agostini March 7, 2022

My automation rule runs only indicate in addWatcher {{issue.fields.People.accountId}}.

Kamil Baran April 28, 2022

Definitely {{issue.fields.People.accountId}} should be default functionality 

{{issue.fields.People.displayName}} - Error watching issues

{{issue.fields.People.Name}} No actions were performed.

0 votes
Quyen Nguyen November 17, 2022

I was looking for the same solution and followed the suggestions found on here but couldn't make it work for me. I want to update the system Watchers field with the value added to a custom Watchers field at issue creation.

However, I use the Post Function at Create transition on the workflow and it works great :-)

Add Post Function > Choose "Copy Value From Other Field" > Add > Choose the Source Field as "custom Watchers" (or whatever the name you have for that custom field), Choose Destination Field as the system "Watchers" > Add

0 votes
Reese Schmit February 2, 2022

I've attempted to do this a ton of ways based on previous and this set of answers, but I still am not getting watchers added. It says "success" but no actions performed. HELP! :)

Automation.png

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2022

Use displayName instead of Name

0 votes
Ani Popova September 15, 2021

Forgot to specify that this is a company-managed project.

Suggest an answer

Log in or Sign up to answer