how to add Cascading Select Field to Email?

fabby January 22, 2013

my jira version is 4.4.1

my customer ask me to add Custom Fileds to Email.

in atlasssian-jira\WEB-INF\classes\templates\email\text\issueupdated.vm ,i add below code .

#foreach ($value in $customFieldManager.getCustomFieldObjects($issue))
#if ($value.getValue($issue) && !($value.getName()=="Comments") && !($value.getName()=="TimeSpent_Resolve") && !($value.getName()=="TimeSpent_StartProgress"))
>>$stringUtils.leftPad($value.getName(), $padSize): $!value.getValue($issue)
#end
#end

email can display most fields normally.but the Cascading Select Field seems not.

it display as

CSField:CustomFieldParams:CSField. Params:{null=[LCD],1=[WWG]}.

5 answers

1 accepted

2 votes
Answer accepted
fabby January 22, 2013

i resolved it.

#foreach ($value in $customFieldManager.getCustomFieldObjects($issue))
#if ($value.getValue($issue) && !($value.getName()=="Comments") && !($value.getName()=="TimeSpent_Resolve") && !($value.getName()=="TimeSpent_StartProgress"))
#if($!value.getCustomFieldType().getName()=="Cascading Select")
>>$stringUtils.leftPad($value.getName(), $padSize): $!value.getValue($issue).getFirstValueForNullKey()/$!value.getValue($issue).getFirstValueForKey("1")
#else
>>$stringUtils.leftPad($value.getName(), $padSize): $!value.getValue($issue)
#end
#end
#end

1 vote
Jared Lynem October 6, 2015

This works to get the two values from the cascading select.

First value:

 

<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("My Cascading Select Custom Field Name")).get(null) %>

 

Second value:

 

<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("My Cascading Select Custom Field Name")).get("1") %>
Nick Abdoo October 6, 2015

This works great! Thanks :)

0 votes
Operations cdn June 29, 2014

Hello,

My JIRA vesrion is v4.4.3

I am trying to display cascading select custom field (named 'Servicios') values in a custom email, using post functions on the workflow.

- This is the template code:

Servicios afectados: <% if (cfValues['Servicios']) out << cfValues['Servicios'] %>

- Values are displaying like this:

Servicios afectados: CustomFieldParams: Servicios. Params: {null=[OSS], 1=[OVO]}

How can I display only values (i.e OSS,VIVO? What I want is to remove the remaining words on the line above and show only the values.

Which code should be used in the email template for post functions? My code in .vm templates works properly, but in post functions templates this code does not work properly.
Thanks a lot in advance.

0 votes
ohernandez
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 19, 2014

Hi all,

The answer from https://answers.atlassian.com/questions/54609/cascading-select-custom-field-in-jira-5-email-templatesapplies here too:

<tt>getCustomFieldValue</tt> is a method on the <tt>Issue</tt> object, specified in the api at https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/Issue.html

Accordingly, the return value is defined as:

A custom field's value. Will be a List, User, Timestamp etc, depending on custom field type.

Knowing this, by invoking:

$issue.getCustomFieldValue("customfield_11406")

You are getting a <tt>Map<String, Option></tt> where <tt>null</tt> is the key for the parent option and <tt>1</tt> is the key for the child option.

In order to get these values individually it's only necessary to iterate over the Map, for instance:

#foreach( $optionKey in $issue.getCustomFieldValue("customfield_11406").keySet() )
    &lt;li&gt;Key: $optionKey -&gt; Value: $issue.getCustomFieldValue("customfield_11406").get($optionKey)&lt;/li&gt;
#end

The above should work for JIRA 6.2.x

0 votes
Operations cdn May 14, 2014

Hello,

I have the same problem:

CustomFieldParams: Servicios. Params: {null=[CDN SERVICE], 1=[Ingest]}.

I am trying to display a cascading select field in email notifications, but using post functions.

Which code it should be used in this case?

Thanks a lot in advanced.

Suggest an answer

Log in or Sign up to answer