Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected list value in script field in jira.

Mangesh Rane February 7, 2018

Hi,

 

I have following code but it returns null values.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.fields.CustomField;

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customField = customFieldManager.getCustomFieldObject('customfield_19115');
def str = issue.getCustomFieldValue(customField);
return str.toString()

I ave feeling select list vs string field is issue, but not sure how to resolved.

Please let me know the solution. 

Thanks

 

1 answer

0 votes
Julian Riedinger [Decadis AG]
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.
February 7, 2018

Hey Mangesh,

in which context do you run your script? As a scripted field? Is the refernece to the custom field valid? Does the given issue have set a field value? What is the type of the field with the id 19115

 

Cheers,

Julian

Mangesh Rane February 7, 2018

Hi

 

Yes, I am running the code as a scripted field. 

Yes, the reference to the custom field is valid as well.

 

Also, 19115 is select list type field.

 

Thanks

Mangesh

Julian Riedinger [Decadis AG]
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.
February 7, 2018

assuming you have a single select field and the given issue has a value your script should work. I've just tested it on a staging environment.

Just to be sure - when I work with the preview function adding a scripted field, I sometimes make the mistake to enter an issue key with lowercase letters. The result is that I get null values. So my question is, where you get the null values? In the preview or when opening an issue? If you get those in the preview - Did you entered the issue key correctly?

 

Cheers,

Julian

Mangesh Rane February 7, 2018

Hi,

The issue was, on a scripted field screen there is a field called: Template, I changed to Text field, instead of a number field.

 

Thanks for your response though

Mangesh

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events