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

2 votes
Accepted answer

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 Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,767 views 18 21
Read article

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