import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.user.ApplicationUser // Define the issue keys you want to search for def issueKeys = ["KEY-123", "KEY-124", "KEY-125"] // change keys as needed IssueManager issueManager = ComponentAccessor.getIssueManager() CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() def userManager = ComponentAccessor.getUserManager() // Replace 'CustomFieldName' with the name of your custom field CustomField customField = customFieldManager.getCustomFieldObjectsByName("Product Owner")[0] issueKeys.each { key -> Issue issue = issueManager.getIssueByCurrentKey(key) if (issue) { ApplicationUser user = userManager.getUserByName("john_Doe") // Replace 'caselc' with the username of the user you want to set if (user) { issue.setCustomFieldValue(customField, user) issueManager.updateIssue( ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false ) } else { println "User not found for key $key" } } else { println "Issue not found for key $key" } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter