How to retrieve checkbox custom field values

David Antebi August 12, 2018

Hi,

I'm using the script below to retrieve checkbox custom field values.
However, when I search the log I see that although I selected one option from the checkboxes, I receive a null value in the script.

Please help me to understand what I'm doing wrong?!

//deal Deal Types field
CustomField dealDealTypes = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("deal Deal Types");
List<Option> options = (List<Option>)dealDealTypes.getValue(issue);
def ss = options.toString()
logd.debug(" options: " + options)
logd.debug(" ss: " + ss)

 

Thanks!

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2018

Hello,

Where do you execute this script?

Try to do like this:

CustomField dealDealTypes = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("deal Deal Types");
def options = issue.getCustomFieldValue(dealDealTypes);
def ss = options.toString()
logd.debug(" options: " + options)
logd.debug(" ss: " + ss)
David Antebi August 13, 2018

Thanks for your answer but now I receive this message in the log:

 

2018-08-14 09:38:56,028 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
java.lang.NullPointerException
 at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:898)
 at com.atlassian.jira.issue.Issue$getCustomFieldValue$3.call(Unknown Source)
 at Script349.run(Script349.groovy:29)

 I'm running this script in workflow validator.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 14, 2018

What is line 29 in your script?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events