Hi Team,
With Jira upgrade to 9, JiraUtils.loadComponent method is not supported
We are currently facing the issue with JiraUtils.loadComponent method. Its no longer supported. Kindly help us with the compatible method.
Below is the code used:
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.issue.search.SearchQuery
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller()
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
Long results = null;
CustomField parentLink = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Parent Link").getAt(0)
String parentKey = issue.getCustomFieldValue(parentLink)
IssueManager issueManager = ComponentAccessor.getIssueManager()
MutableIssue parent = issueManager.getIssueByKeyIgnoreCase(parentKey)
def isDevBacklogStatus = parent.getStatus().getSimpleStatus().getName() in ['In Progress']
if (isDevBacklogStatus) {
def jqlSearch = jqlQueryParser.parseQuery("'Parent Link'= " + parentKey + " AND statusCategory not in (Done) AND key != " + issue.getKey());
def searchQuery = SearchQuery.create(jqlSearch, user)
results = searchProvider.getHitCount(searchQuery)
}
if (results == 0) {
workflowTransitionUtil.setIssue(parent)
workflowTransitionUtil.setUserkey(currentUser)
workflowTransitionUtil.setAction(21)
if (workflowTransitionUtil.validate()) {
workflowTransitionUtil.progress()
}
}
Highlighted code gives error during execution. Kindly help us with the correct method.
Waiting for a quick reply.
Thanks
Lipsa