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

Groovy : update issue reporter with are particular user

I have a user given to me via a request from and I want to use groovy to update the report. I worked out how to locate the user object from searching the user's ID number. (Jira links into our companies Active Directory).

 

def userName = "U00001"
	def userObject = ComponentAccessor.getUserManager().getUserByName(userName)
	

The object consists of these elements:

 

 

2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: key = u00001
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: directoryId = 10000
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: directoryUser = U00001:10000
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: emailAddress = Samuel.SURNAME@company.com.au
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: username = U00001
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: name = U00001
2017-04-11 12:29:29,737 WARN [runner.ScriptRunnerImpl]: displayName = SURNAME, Samuel

 

Now I can't work out how to set the reporter to this user object.

I have tried this code but it just update's the field and I can see jira does not see it as a user. It's just text sitting in the report field. 

issue.reporterId = userObject.displayName
issue.store()

I took this idea from this post. I tried the same method in the answer and set the current logged in user as the repoter, but jira still doesn't see it as a user object.

issue.reporterId = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
issue.store()

https://community.atlassian.com/t5/JIRA-questions/Set-issue-reporter-via-groovy-script/qaq-p/422498

 

1 answer

Just worked it out. This may be unique to my situation as my Jira is integrated with Active Directory.

I used .key

def userName = "U000001"
def userObject = ComponentAccessor.getUserManager().getUserByName(userName)
issue.reporterId = userObject.key
issue.store()

 

 

Suggest an answer

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

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

365 views 5 4
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