Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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)

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
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - Spring 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

129 views 3 15
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you