Hi,
I have a code that takes a custom field value.
This custom field is 1 checkbox- "Yes".. If it chosen, the value is 'Yes' and if it doesn't, the value is null.
I use those lines:
def internal = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Internal Feature");
def selectedValues1 = internal.getValue(featureIssue);
def selectedValues2 = internal.getValue(issue);
When the value is null, The code didn't run, and send this error:
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script> java.lang.NullPointerException at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.getValueFromIssue(AbstractMultiCFType.java:150) at com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType.getValueFromIssue(AbstractMultiCFType.java:39) at com.atlassian.jira.issue.fields.ImmutableCustomField.getValue(ImmutableCustomField.java:350) at com.atlassian.jira.issue.fields.CustomField$getValue$1.call(Unknown Source) at Script1099.run(Script1099.groovy:52)
Can someone help me to understand how can I do it ?
Tnx !
Hello @Dan27
Use getCustomFieldValue() instead of getValue()
def internal = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Internal Feature");
def selectedValues1 = featureIssue.getCustomFieldValue(internal)
def selectedValues2 = issue.getCustomFieldValue(internal)
A what is in the line 52?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.