Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Scriptrunner script to add watchers from email value

Hi,

Am I able to use Scriptrunner to add a Watcher using an email address as the value? The email address would come from custom field type "Text Field (single line)". This script would run on the "Create" transition of the Issue workflow.

I've had a look at some example scripts but my understanding of Groovy is very limited.

Any assistance would be very much appreciated.

Thanks,

Andrew

 

 

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Alejandro Suárez - TecnoFor
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Feb 23, 2019

Hi @Andrew Henders  , you cant, unless that user is added in Jira.

Regards

Thanks for the reply Alejandro. Only an email address, of users already in the JIRA internal directory, would be used.

This thread seems to contain some scripts that may get me there - https://community.atlassian.com/t5/Answers-Developer-Questions/How-do-I-add-a-specific-user-as-a-watcher-using-script-runner/qaq-p/569185

Could anyone please suggest a change to the below script that would allow the use of the user account email address instead of user name?

 

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.MutableIssue

import com.atlassian.jira.user.ApplicationUser

MutableIssue issue = issue

def cfManager = ComponentAccessor.getCustomFieldManager()

def watcherManager = ComponentAccessor.getWatcherManager()

def cf = cfManager.getCustomFieldObject(“12046”)

def u1 = issue.getCustomFieldValue(cf) as ApplicationUser

watcherManager.startWatching(u1, issue)

 

Please note, I'm getting an error when running the above script but seems to be close to what I would require.

Any assistance appreciated.

Cheers,

Andrew

TAGS
AUG Leaders

Atlassian Community Events