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?
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.