Hello Team,
I am using below code to create sub-task but i am getting error as in attached screenshot.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.security.JiraAuthenticationContext
def constantManager = ComponentAccessor.getConstantsManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def issueManager = ComponentAccessor.getIssueManager()
//Issue parentIssue = issue
def parentIssue = issueManager.getIssueObject("PUN-470")
if (parentIssue.getIssueTypeObject().getName() == 'Sub-task')
return
//create new issue as sub task
def newSubtask = issueFactory.getIssue()
newSubtask.summary = "new subtask"
newSubtask.description = "subtask explanation"
newSubtask.setProjectId(parentIssue.getProjectId())
newSubtask.setIssueTypeId("143454") //issue type id must be subtask type's id
newSubtask.setParentId(parentIssue.getId())
newSubtask.setAssigneeId("user1")
newSubtask.setReporterId("user2")
newSubtask = issueManager.createIssueObject(user, newSubtask)
//link subtask to parent task
def subTaskManagerLink = ComponentAccessor.getSubTaskManager()
subTaskManagerLink.createSubTaskIssueLink(parentIssue, newSubtask, user)
parentIssue.store()
