Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Why everyone using Jira must be GDPR-compliant

Did you know that penalties up to 4 % of the yearly company turnover are possible in case of GDPR violations? GDPR regulations are currently mainly relevant for companies in the EU, but countries lik...

81 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you