I am currently trying to clone a subtask and then with the new cloned issue attach it to a parent that already exists, here is my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueFactory
import com.atlassian.jira.issue.IssueManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
IssueFactory issueFactory = ComponentAccessor.getIssueFactory()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def subTaskToCopy = issueManager.getIssueObject("EN-222")
def PSDCF = customFieldManager.getCustomFieldObjectsByName("Planned Start Date")[0]
def PEDCF = customFieldManager.getCustomFieldObjectsByName("Planned End Date")[0]
def list = ['EN-35', 'EN-32', 'EN-27']
list.each {workPackage ->
def issue = issueManager.getIssueObject(workPackage)
log.debug (issue.getSummary())
def issuePSDCFV = issue.getCustomFieldValue(PSDCF)
def issuePEDCFV = issue.getCustomFieldValue(PEDCF)
def newSubTaskCloner = issueFactory.cloneIssueWithAllFields(subTaskToCopy)
newSubTaskCloner.setCustomFieldValue(PSDCF, issuePSDCFV)
newSubTaskCloner.setCustomFieldValue(PEDCF, issuePSDCFV)
def newSubTaskCreate = issueManager.createIssueObject(user, newSubTaskCloner)
subTaskManager.createSubTaskIssueLink(issue, newSubTaskCreate, user)
}
This returns this error
java.lang.NullPointerException at com.atlassian.jira.issue.link.DefaultIssueLinkManager.getIssueLink(DefaultIssueLinkManager.java:381) at com.atlassian.jira.issue.link.DefaultIssueLinkManager.createIssueLink(DefaultIssueLinkManager.java:89) at com.atlassian.jira.config.DefaultSubTaskManager.createSubTaskIssueLink(DefaultSubTaskManager.java:443) at com.atlassian.jira.config.SubTaskManager$createSubTaskIssueLink.call(Unknown Source) at Script402$_run_closure1.doCall(Script402.groovy:34) at Script402.run(Script402.groovy:23)
I have checked all variables have a value at point of creating the parent link, which they do.
I think the issue is with the parent issue that I am passing accross, what method should I be using to get the parent issue? bearing in mind that the parent existed before this script, as issueManager.getIssueObject() doesn't seem to be working.
anybody having issues with this?
I have used subtaskManager.createSubtaskIssueLink() before, but when used before the parent issue was created in that script too.
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.