I have a transition that creates a bunch of sub tasks. when a particular subtask is created, I want to create a link issue using the "Clones an issue, and links [ScriptRunner]" post function. Under the condition section, I have this:
issue.summary.matches("MM conducts Table 3 Training(.*)") && issue.issueType.name == "PCT Sub-Task" this works fine when I tested it with additional issue actions and set the summary to below
issue.summary = 'Test'
Now, I have a custom field that I want to copy from the parent task that triggered the subtask and this linked task, so I created the script below
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
Issue parentIssue = issue.getParentObject()
def proj = ComponentAccessor.getProjectManager().getProjectByCurrentKey("PCT").id
def pct = parentIssue.issueType.name as String
def cfMgr = ComponentAccessor.getCustomFieldManager()
def newCHAOCf = cfMgr.getCustomFieldObjects(proj, pct).find {it.name == 'New CH/AO'}
def newCHAO = parentIssue.getCustomFieldValue(newCHAOCf) as ApplicationUser
MutableIssue mm_task = ComponentAccessor.getIssueFactory().getIssue()
mm_task.summary = ('Conduct ILT for New CH/AO' + ' [' + newCHAO.getDisplayName() + ']') as String
I am getting the error below:
java.lang.NullPointerException: Cannot get property 'issueType' on null object
it seems like it is not getting the parent issue object properly. Any input would be much apprecaited. Thank you.