Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×I have this Listener (below). What I want to happen:
When the issue type is set as 'Enhancement Request' by a specified author, assign the issue to another specified user (user).
If the event author is not the user I've specified, ignore this auto-assignment.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Category;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.INFO)
Issue issue = event.issue as MutableIssue
def issueObject = issue.getKey()
def author = event.getUser().getDisplayName()
if( ["Enhancement Request"].contains(issue.issueType.name) && author == {string username})
{ log.info 'Issue Type is Enhancement Request.'
def userManager = ComponentAccessor.getUserManager()
def user = ComponentAccessor.getUserManager().getUserByKey({string username})
def admin = userManager.getUserByName({string username})
issue.setAssigneeId(user)
return "Author = " + { log.info author.toString() };
return "Assignee = " + { log.info user.toString() };
}
For those of you wondering, I retooled the script and was able to solve it. Here it is:
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
UserManager userManager = ComponentAccessor.getUserManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
def issue = event.getIssue() as MutableIssue
def author = event.getUser().name.toString()
final List<String> projTeam = ['user1', 'user2', 'user3', 'user4']
ApplicationUser assignToUser = userManager.getUserByKey('user5')
if (["Enhancement Request"].contains(issue.issueType.name) && author in projTeam) {
issue.setAssignee(assignToUser)
issueManager.updateIssue(assignToUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
log.info(author + " changed ticket to Enchancement Request.")
}
else
log.info("Non-projTeam user switched issue to Enhancement Request.")
Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!
Start Learning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.