Set issue reporter via groovy script

Hi folks,

maybe a stupid question, but i don´t find what i´m doing wrong here:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;
issue.reporterId = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

This is a groovy scripted post function to change a cloned issues´ reporter to the current user (instead of the reporter of the to be cloned issue), after changing from componentManager to ComponentAccessor this is in general working.

But, while testing it it looks a bit weird:

image2017-1-4 18:22:58.png

You see, the assignee was cloned and the correct name was set, but the reporter was somehow changed to the username instead. Tried to find a solution by myself but without success... sad

 

Many thanks!

1 answer

1 accepted

3 votes

Your assigning an com.atlassian.jira.user.ApplicationUser object in JIRA 7 or a com.atlassian.crowd.embedded.api.User object in JIRA 6 to the reported id. 

The reported id should be the username. So you need:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;
issue.reporterId = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name

Hi Adam,

thanks, is working as expected! Seems that i "only" missed the ...getLoggedInUser().name

Just for other users, this was tested with JIRA 7.1.7 and ScriptRunner 4.3.13...

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,959 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot