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...
Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!
Register todayOnline 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.