how to add Cascading Select Field to Email?

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

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

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.

0 votes

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

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.

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

First value:

 

&lt;% out &lt;&lt; issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("My Cascading Select Custom Field Name")).get(null) %&gt;

 

Second value:

 

&lt;% out &lt;&lt; issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("My Cascading Select Custom Field Name")).get("1") %&gt;

This works great! Thanks :)

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,089 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot