Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
  • Community
  • Q&A
  • Jira
  • Questions
  • Groovy Script that sets the reporter of an issue (type subtask) to the reporter of it's parent issue

Groovy Script that sets the reporter of an issue (type subtask) to the reporter of it's parent issue

Jan Mueller August 1, 2018

I'm looking for a groovy script to set the reporter of an issue (sub-task) to the same user as it's parent issue. 

It shall be used on a post-function via script runner. 

2 answers

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2018

Hello,

Your script would look like this:

if (issue.getParentObject() != null)

  issue.setReporter(issue.getParentObject().getReporter())

Jan Mueller August 2, 2018

Thank you! 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2018

You are welcome!

0 votes
Merch Ops Analyst
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 26, 2018

I have the following script in our Script Listener for JIRA Cloud. 

 

// Auto assign reporter of parent ticket as reporter of all sub-tasks
def issueKey = issue.key

// if current issue is a sub-task
if (issue.fields.issuetype.subtask == true){

// get parent ticket
def parent = get('/rest/api/2/issue/' + issue.fields.parent.key)
.header('Content-Type', 'application/json')
.asObject(Map).body

// change reporter on current ticket
def issue_reporter = put('/rest/api/2/issue/'+ issueKey)
.header('Content-Type', 'application/json')
.body([
fields: [
reporter: parent.fields.reporter
]
]).asObject(Map).body

}

Suggest an answer

Log in or Sign up to answer