Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Transition parent when sub-task is transitioned script is failing after upgrade of Jira to 9.4.1

Jagadeesh Chander February 2, 2023

Transition parent when sub-task is transitioned script is failing after upgrade of Jira to 9.4.1

here is my script

 

import com.atlassian.jira.component.ComponentAccessor;
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;

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();

def workflowTransitionUtil = ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class)
//WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
MutableIssue parent = issue.getParentObject() as MutableIssue;
String originalParentStatus  = parent?.status?.name
String issueStatus = issue?.status?.name

if (issue.issueType.name == "Sub-Task" && issueStatus == 'Ready for Development' && ( originalParentStatus == 'Backlog' || originalParentStatus == 'Ready for Refinement' || originalParentStatus == 'Ready for Development' ) ) {
    workflowTransitionUtil.setIssue(parent)
    workflowTransitionUtil.setUserkey(currentUser)
    workflowTransitionUtil.setAction(131)
    workflowTransitionUtil.validate()
    workflowTransitionUtil.progress()
}
error my getting is 
2023-02-03 07:44:36,836 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue MTP-458 for user 'srjag'. View here: https://jira-preprod.nets.no/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=New+MS+TMS+Task+%26+Sub+Task+Workflow&descriptorTab=postfunctions&workflowTransition=141&highlight=1 java.lang.NullPointerException: Cannot invoke method setIssue() on null object at Script202.run(Script202.groovy:17)
can anyone help me to fix this

1 answer

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
February 6, 2023

Hi @Jagadeesh Chander 

The error message says that workflowTransitionUtil object is null, meaning that the component is not being loaded correctly. This can be due to changes in the Jira API before the version 9.4.1. I am not sure but could you please try below solution?

Instead of this

def workflowTransitionUtil = ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class)

use this

WorkflowTransitionUtil workflowTransitionUtil = ComponentAccessor.getWorkflowTransitionUtil()

I hope it helps

Jagadeesh Chander February 6, 2023

Hi

@Tuncay Senturk _Snapbytes_ 

 

Thanks for your response 

i change the code but still its failing the error now I got

023-02-07 05:12:53,601 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue MTP-484 for user 'srjag'. View here: https://jira-preprod.nets.no/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=New+MS+TMS+Task+%26+Sub+Task+Workflow&descriptorTab=postfunctions&workflowTransition=141&highlight=3
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.component.ComponentAccessor.getWorkflowTransitionUtil() is applicable for argument types: () values: []
at Script11.run(Script11.groovy:13)

Suggest an answer

Log in or Sign up to answer