How to add a multi select (dropdown) custom field value to custom email [script runner postfunction]

Bahar Dehkordi July 27, 2018

The below query doesn't seem to work when the custom field type is a select list (multiple choices) 

Custom field value: <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MySelect")) %>

Any idea how I can solve this? Thanks in advance!

 

2 answers

2 accepted

1 vote
Answer accepted
Henning Tietgens
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.
July 29, 2018

Please try 

Custom field value: <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MySelect"))*.getValue().join(', ') %>

For a multiselect list getCustomFieldValue() returns a collection of Option object. With *.getValue() you convert this collection to a collection of the values of these Option objects. The value is the text the user sees. With join(', ') you convert this collection to one string, if there are multiple values these are separated by a comma.

Henning

Bahar Dehkordi July 30, 2018

Thank you for the explanation, it works. 

1 vote
Answer accepted
Mark Markov
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.
July 27, 2018

Hello @Bahar Dehkordi

Try

Custom field value: <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MySelect")).toString() %>

Bahar Dehkordi July 30, 2018

Thank you, works!

Suggest an answer

Log in or Sign up to answer