Hi Team,
With the use of
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class)
setIssue() is throwing java.lang.NullPointerException.
Can someone help with the correct method/value to be passed.
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.CustomFieldManager; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.component.ComponentAccessor; String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller() //WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class) WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class) CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager(); CustomField epicLink = customFieldManager.getCustomFieldObjectsByName('Epic Link').getAt(0) MutableIssue parent = (MutableIssue) issue.getCustomFieldValue(epicLink); if (parent != null) { log.warn "${parent.getSummary()}" log.warn "${parent.getStatus().getSimpleStatus().getName()}" def isDevBacklogStatus = parent.getStatus().getSimpleStatus().getName() in ['New'] log.warn "${isDevBacklogStatus}" if (isDevBacklogStatus) { workflowTransitionUtil.setIssue(parent)<----Issue is here workflowTransitionUtil.setUserkey(currentUser) workflowTransitionUtil.setAction(11) if (workflowTransitionUtil.validate()) { log.warn "inside validate" workflowTransitionUtil.progress() } } }
Regards
Lipsa
Welcome to the Atlassian Community!
The NPE on that line means that the "parent" variable contains a null, not the issue object that the function needs.
So my guess would be that the parent issue the script is running against does not have an Epic link (or the code on the line "MutableIssue parent = ..." is wrong, although it looks ok at a glance to me)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't run the script for issues that do not have an epic link?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.