Hi, I added new custom field in my project. And now I want to get my custom field value, when I'm clicking the button of "Create" issue, so and I'm using this code
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
//Debug
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("10301")
def cFieldValue = issue.getCustomFieldValue(cField)
log.info("Field Value="+cFieldValue+"URL="+url+" Status="+connection.getResponseCode() as
String)
But I'm getting this error... this is my log:
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2020-05-26 13:40:41,732 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2020-05-26 13:40:41,733 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:896) at com.atlassian.jira.issue.Issue$getCustomFieldValue$2.call(Unknown Source) at Script123.run(Script123.groovy:23)
What's wrong?
Try either
def cField = customFieldManager.getCustomFieldObject(10301)
Or
def cField = customFieldManager.getCustomFieldObject("customfield_10301")
Thank you!! The second variant very helpful...("customfield_10301"). It works perfectly..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.