You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!

1

Automatically Update the Assignee of an Issue in Jira

Overview

Automatically update the Assignee field of an issue in Jira with this snippet.

Example

I can use this snippet as part of a larger script, so if an issue isn't updated within seven days, the assignee changes automatically.

Requirements

  • Jira Jira (8.0 - 8.14)
  • ScriptRunner for Jira ScriptRunner for Jira (6.18.0)
    
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.IssueInputParametersImpl // the issue key to update final String issueKey = "JRA-1" // the username of the new assignee final String newAssigneeId = "admin" // change to 'true' if you want to send an email if the update is successful final boolean sendMail = false def issueService = ComponentAccessor.issueService def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issueKey) assert issue : "Could not find issue with key $issueKey" def issueInputParameters = new IssueInputParametersImpl() issueInputParameters.setAssigneeId(newAssigneeId) def updateValidationResult = issueService.validateUpdate(loggedInUser, issue.id, issueInputParameters) assert updateValidationResult.valid : updateValidationResult.errorCollection def issueUpdateResult = issueService.update(loggedInUser, updateValidationResult, EventDispatchOption.ISSUE_UPDATED, sendMail) assert issueUpdateResult.valid : issueUpdateResult.errorCollection
Discovered an issue? Report it here

Suggested for you