Hi,
I had a working script but after upgrade to JIRA 8.5. I have to replace component manager.
I did that but now i get Null pointer exception.
Below is the script. Any help is appreciated.
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.ComponentManager
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.util.SimpleErrorCollection
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.config.ResolutionManager
import org.apache.log4j.Logger
import static org.apache.log4j.Level.DEBUG
log.setLevel(org.apache.log4j.Level.DEBUG)
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions
import com.atlassian.jira.issue.IssueInputParameters
GroupManager groupManager = ComponentAccessor.getComponent(GroupManager.class)
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
CustomField cf = cfManager.getCustomFieldObject(11907);
Object customFieldValue = (Object) issue.getCustomFieldValue(cf)
Issue parent = issue.getParentObject();
def issueLinkManager = ComponentAccessor.getIssueLinkManager();
def issueManager = ComponentAccessor.getIssueManager();
def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)
IssueService issueService = ComponentAccessor.getIssueService()
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class);
boolean check = false;
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
issueLinkManager.getOutwardLinks(issue.getId()).each
{
issueLink ->
MutableIssue linkIssue = issueLink.getDestinationObject() as MutableIssue
if(linkIssue.summary == ('REQ ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary()))
{
if(linkIssue.resolution?.name == 'Fixed')
{
check = true;
}else
{
check = false;
}
}
}
issueLinkManager.getOutwardLinks(issue.getId()).each
{
issueLink ->
MutableIssue linkIssue = issueLink.getDestinationObject() as MutableIssue
if((linkIssue.issueType.name == 'Design & Code' || (linkIssue.issueType.name == 'Test Prep.')) && ((linkIssue.summary == 'D&C ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary()) || (linkIssue.summary == 'TP ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary())) && (linkIssue.status.name == 'Closed') && (linkIssue.resolution?.name == 'Fixed') && check )
{
workflowTransitionUtil.setIssue(linkIssue); <== ISSUE HERE
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(51);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
Hello @Madhavan Jayabalan, I am running Jira v8.5.3. I do not get the error you get, and my script is run as a "Script Listener".
I'm doing it slightly differently, have you tried replacing:
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class);
with
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
I wouldn't think that will matter, but I'm also setting
workflowTransitionUtil.setIssue(issue);
but here, my 'issue' is of type 'Issue', not of type 'MutableIssue'.
Hi Madhavan,
there have been some changes when upgrading to Jira v8. You mentioned the replacement of the ComponentManager - this is indeed a significant one. From my experience simple replacing it won't work.
The Groovy scripts needs a rework in some cases.
Have you checked the documentation on this?
https://scriptrunner.adaptavist.com/5.6.8/jira/releases/UpgradingToJira8.html#_componentmanager_has_been_moved
In case you don't get along with the generic documentation please state where the NPE exactly occurs. The likeliness is then higher that somebody from Community will look into the code and give an advise.
Cheers,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
Thanks for the support.
I referred the documentation you have referred but still i am unable to make my script working. Looks i'm missing some basics.
In the script which i have in the description(above). I see that linkIssue is null. Eventhough i'm able to get summary and issue type etc from linkIssue.
workflowTransitionUtil.setIssue(linkIssue); <== ISSUE HERE
Cheers,
Madhavan.J
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Madhavan Jayabalan ,
Did you get any resolution to your issue?
I am also facing the same error
workflowTransitionUtil.setIssue(parent) <== Issue is here
I have even replaced
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.