I would like to update the reporter according to the issue type.

Jeoung April 6, 2020

Hello, I am using Scriptrunner. When I create an issue, I want to update the reporter according to the issue type.

Ex) If the issue type is bug, the reporter is user1,

     and if the issue type is Task, the reporter is user2.

What should I do?

1 answer

1 accepted

0 votes
Answer accepted
Leonard Chew
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.
April 6, 2020

Hi there

You can do that with a postfunction script on the create transition.

Place the script below the "Creates the issue originally" step.

Here's a script that should do the job

import org.apache.log4j.Level
log.setLevel(Level.INFO)

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def user1 = ComponentAccessor.getUserManager().getUserByName('martin.ziswiler')
def user2 = ComponentAccessor.getUserManager().getUserByName('christoph.erni')

switch (issue.issueType.name) {
case "Bug":
log.info("Setting Reporter on Issue "+ issue.key + " to user " + user1)
issue.setReporter(user1)
break
case "Task":
log.info("Setting Reporter on Issue "+ issue.key + " to user " + user2)
issue.setReporter(user2)
break
}

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Jeoung April 6, 2020

It's perfect to run with the script you suggested!

Thank you !!!

Like Leonard Chew likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events