Use case
Add watchers to an issue from any field, be it, for example, the Assignee or the Reporter fields.
Using this combination of functions in several transitions will enable you to add several watchers if the user of the field changes, but not to remove them.
⚒️ Configuration
Set up the custom field and the transitions that you are going to use.
Create a default User Picker (multiple users) field, and name it All watchers
Create a global reflexive transition (a transition from any issue to itself).
Set up the Update fields post function
Add a Update fields post function to any workflow transition but the global reflexive one. The Create issue transition can be a good choice here.
Target issue
Choose Current issue
Fields
Choose All watchers
Value
In the popup, choose the value Set field value manually (parser expression)
Expression
Enter the following expression :
%{union(union(toStringList(%{issue.cf10001}), toStringList(%{issue.assignee})), toStringList(%{issue.watcher}))
with parsing mode set to General and replace the field code %{issue.cf10001} with the field code for the field All watchers
As it is, the expression will take the value of the Assignee field. It could be changed for the Reporter field or for a custom User Picker field replacing the field code %{issue.assignee} with the one of your choice.
Run as
Choose Current user
Set up the Transition issue post function
Add a Transition issue post function to the same transition as the previous post function.
Target issue*
Select Current issue
Mode*
Select Execute transition
Select the transition to be executed
Select the global reflexive transition previously created.
Delayed execution
Delay the execution of the post function 1000 milliseconds .
Set up a Copy Value From Other Field post function
Add a Copy Value From Other Field Jira post function.
Source Field
Select All watchers
Destination Field
Select Watchers
📚 Related use cases