NullPointerException when getting custom field value post function

Using below code for a custom field which is also a required field( Single Choice list), still getting below error, Need help !!


<Field Name> <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("<Field Name> ") %>




       at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(

       at com.atlassian.jira.issue.Issue$getCustomFieldValue$ Source)

       at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(



       at groovy.tmp.templates.GStringTemplateScript5$_getTemplate_closure1.doCall(GStringTemplateScript5.groovy:15)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

       at java.lang.reflect.Method.invoke(Unknown Source)

       at org.codehaus.groovy.reflection.CachedMethod.invoke(

       at groovy.lang.MetaMethod.doMethodInvoke(


       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(


       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

       at java.util.concurrent.ThreadPoolExecutor$ Source)

       at Source)

1 answer

0 vote
Alexey Matveev Community Champion Dec 06, 2017


The problem is that your variable componentManager is unknown.

it shoud be 

issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("<Field Name> "))

But you would need to make an import

import com.atlassian.jira.component.ComponentAccessor

Thanks Alexey, Could you please suggest that how can we import library in the email section. 


<Field Name> <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("<Field Name> ")) %>


Tried, still getting the same error.

Please if you can suggest more solutions.

Thanks in Advance.

Alexey Matveev Community Champion Dec 06, 2017

What do you pass for <Field Name> ? Make sure the field really exists

Required Order Contract Term (in months): <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Required Order Contract Term (in months)")) %>


Required Order Contract Term (in months) -  It's a field

Alexey Matveev Community Champion Dec 06, 2017

Somehow the field is not found in your Jira instance. Or the error is actually different

Hello Alexey

The issue was with the field only, re-indexing has fixed this issue.

Many Many Thanks for Your help :)

Alexey Matveev Community Champion Dec 07, 2017

Nice to hear. Good luck.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 6 hours ago in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

18 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you