Script does not work after upgrading to JIRA 7.x

We upgraded JIRA and script runner and this code stopped working.  Has this happened to anyone?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption

import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.debug "debug statements"
//MutableIssue issue = (MutableIssue) ComponentAccessor.getIssueManager().getIssueObject("")
def issue = (MutableIssue) issue
log.debug "issue"
//getting and defining custom fields for future logic
def customFieldManager = ComponentAccessor.getCustomFieldManager()
log.debug "customFieldManager"
//finding the custom field Category object
def customField = customFieldManager.getCustomFieldObjects(issue).find { == "Category" }
log.debug "customField1"
//defining category as the value for Category a string
def category = (String) issue.getCustomFieldValue(customField)
log.debug "category"
//redefining 'customField' to the Internal Vendor POC object
// change from == "Internal Vendor User" to == "Vendor (Internal)" for PCS-21548
customField = customFieldManager.getCustomFieldObjects(issue).find { == "Vendor (Internal)" }
log.debug "customField2"
//defining internalVendor as the value from the Internal Vendor POC object
def ApplicationUser internalVendor = (ApplicationUser) issue.getCustomFieldValue(customField)
log.debug "appUser"
//allows for certain operations and functions to be used for future logic
def issueManager = ComponentAccessor.getIssueManager()
log.debug(category)"Internal Vendor:" + internalVendor)

//getting all issue links of type Location (to find the Site Bio)
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueLinks = issueLinkManager.getOutwardLinks("Issue Found: " + issue.getKey())
def subElements = issueLinks.findAll {
}"Sub Elements: " + issueLinks.size())

//fetching the vendor values from the Site Bio
if (issueLinks.size() > 0) {
def link = (IssueLink) issueLinks.get(0)
def myIssue = issueManager.getIssueObject(link.getDestinationId())"Site Bio found: " + myIssue.getKey())
ApplicationUser vendor1 = (ApplicationUser) myIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Video Vendor"))
ApplicationUser vendor2 = (ApplicationUser) myIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(myIssue).find { == "Access Control Vendor" })
ApplicationUser vendor3 = (ApplicationUser) myIssue.getCustomFieldValue(customFieldManager.getCustomFieldObjects(myIssue).find { == "Intrusion Detection Vendor" })"Vendor 1:" + vendor1)"Vendor 2:" + vendor2)"Vendor 3:" + vendor3)

User assignee = issue.getAssignee()"Before If" + assignee)
//Checking the Assignee field, if it's empty we proceed, if not, the assignee remains'
if (assignee == null){"assignee is null " + assignee)
//if internal vendor is null, move to next if statement, else internal vendor = assignee
if (internalVendor == null){
//assigning the issue to the Project Lead
assignee = ApplicationUsers.toDirectoryUser(issue.getProjectObject().getProjectLead())"assignee = project lead " + assignee)
//Checking the category and the first vendor field to set the assignee
if (vendor1 != null && ["Video"].contains(category)) {
assignee = ApplicationUsers.toDirectoryUser(vendor1)"if vendor 1" + assignee)
//checking the category and the second vendor field to set the assignee
} else if (vendor2 != null && ["Access Control"].contains(category)) {
assignee = ApplicationUsers.toDirectoryUser(vendor2)"if vendor 2" + assignee)
} else if (vendor3 != null && ["Intrusion Detection"].contains(category)) {
assignee = ApplicationUsers.toDirectoryUser(vendor3)"if vendor 3" + assignee)
} else {
assignee = ApplicationUsers.toDirectoryUser(internalVendor)"if internal vendor" + assignee)
}"Assignee: " + assignee)

//issueManager.updateIssue(assignee, issue, EventDispatchOption.DO_NOT_DISPATCH, false)"Issue Assignee: " + issue.getAssignee())
}"Assignee: " + assignee)"Issue Assignee: " + issue.getAssignee())

1 answer

1 accepted

1 vote
Accepted answer

Hi @Michael Bibby,


In short, you are receiving errors because all ComponentManager methods have been removed. Instead, your code should utilize ComponentAcessor. You should remove ComponentManager and import ComponentAccessor instead:

import com.atlassian.jira.component.ComponentAccessor

To get the CustomFieldManager, you should access it through ComponentAcessor:

def customFieldManager = ComponentAccessor.getCustomFieldManager()

Until you make these modifications, your scripts will fail as they are not compatible with JIRA 7.


Please refer this guide.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,720 views 3 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you