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.
Hello,
Your script would look like this:
if (issue.getParentObject() != null)
issue.setReporter(issue.getParentObject().getReporter())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.