I am getting "java.lang.NullPointerException: Cannot invoke method getCustomFieldValue() on null object " error for the below script.
Please help to how to resolve the issue.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.label.LabelManager
import static com.atlassian.jira.issue.IssueFieldConstants.*
def issueManager = ComponentAccessor.getIssueManager()
def contextIssue = issueManager.getIssueObject(getContextIssueId())
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def epicLinkCf = customFieldManager.getCustomFieldObjectsByName("Epic Link").first()
def linkedEpic = contextIssue.getCustomFieldValue(epicLinkCf) as Issue
LabelManager labelManager = ComponentAccessor.getComponent(LabelManager)
def labels = labelManager.getLabels(contextIssue.id)
if (getBehaviourContextId() == "FEA") {
getFieldById("summary").setFormValue("${contextIssue.summary}")
getFieldById("issuelinks-linktype").setFormValue("delivers")
getFieldById("issuelinks-issues").setFormValue(contextIssue.key)
if ((linkedEpic) != null)
{
getFieldByName("Epic Link").setFormValue(linkedEpic.key)
}
def values = []
labels.each { values.add(it.getLabel()) }
def labelField = getFieldById(LABELS)
labelField.setFormValue(values)
}
Try to change:
def epicLinkCf = customFieldManager.getCustomFieldObjectsByName("Epic Link").first()
To:
def epicLinkCf = customFieldManager.getCustomFieldObjectByName("Epic Link")
also, make sure you have the "Epic Link" field in the issue it fails on...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.