How to remove null in Cascading select?

Maridel Gaffud June 20, 2012

This is the code im using to get the value in CustomField:

$issue.getCustomFieldValue("customfield_10070") or

$customFieldManager.getCustomFieldObject("customfield_10070").getValue($issue)

it gets the CustomField value but it has a {null=} or {null=" ", 1=" "}.

Sample:

{null=Cloud9, 1=Web}

Im using velocity, this code is for notification template.

how to remove the {null=" ", 1=" "}?

The CustomField is a Cascading Select.

Help!

Thanks,

7 answers

1 vote
Nino Kienberg March 20, 2015

Hey all,

i've build a separate field-template for cascading select fields. Just replace the XXXXX with your customfield-ID and in your mail the content will be displayed like "ParentValue - ChildValue".

 

#disable_html_escaping()
<tr>
	<th>$stringUtils.leftPad($issue.getCustomField("customfield_XXXXX").name, $padSize):</th>
	<td>
		#set ($customfield=$issue.getCustomFieldValue("customfield_XXXXX"))
		#set ($start_par=$stringUtils.indexOf($customfield.toString(), '='))
		#set ($start_par=$start_par+1)
		#set ($start_child=$stringUtils.lastIndexOf($customfield.toString(), '='))
		#set ($start_child=$start_child+1)
		#set ($ParentValue=$stringUtils.substring($customfield.toString(), $start_par, $stringUtils.indexOf($customfield.toString(), ',')))
		#set ($ChildValue=$stringUtils.substring($customfield.toString(), $start_child, $stringUtils.lastIndexOf($customfield.toString(), '}')))
		$ParentValue - $ChildValue
	</td>
</tr>

 

This works atleast for 6.3.8.

Linda H September 19, 2018

Nino,

OMG...Hours to find this and it works in 7.6.1.  Yippie!!!!   You just made my day!!!

Thank you, Thank you!!

0 votes
Anand Unadkat
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.
December 10, 2014

<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObject("customfield_XXXXX")).values()*.value%>

<br>
0 votes
Anand Unadkat
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.
November 25, 2014

I have tried @Aaron Roddis code but I get the following error:

No such property: value for class: groovy.lang.Binding

Any ideas how to parse cascading select list without null?

0 votes
Aaron Roddis October 24, 2013

Hi all, ive just used this to select the second string in a Cascading Select. with Version 6.0 of Jira

#set ($value = $issue.getCustomFieldValue("customfield_10000").toString())
#if ($stringUtils.isNotBlank($value))
#set ($childValue=$stringUtils.chop($stringUtils.substringAfterLast($value,'=')))
#if ($stringUtils.isNotBlank($childValue))
$textutils.htmlEncode($childValue)
#end
#end

0 votes
Nelly Le Texier July 14, 2013

Hello,

I found a temporary solution (for example in a templates/email/html/includes/fields/myCustomField.vm):

#disable_html_escaping()
#set ($value = $issue.getCustomFieldValue("customfield_10000").toString())
#if ($stringUtils.isNotBlank($value))
##Example $value: {null=Foo, 1=Bar}
#set ($childValue=$stringUtils.chop($stringUtils.substringAfterLast($value,'=')))
#if ($stringUtils.isNotBlank($childValue))
&lt;tr valign="top"&gt;
    &lt;td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;"&gt;
        &lt;strong style="font-weight:normal;color:${textSubtleColour};"&gt;My Field:&lt;/strong&gt;
    &lt;/td&gt;
    &lt;td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;"&gt;
        $textutils.htmlEncode($childValue)
    &lt;/td&gt;
    ##display "My Field: Bar" only
&lt;/tr&gt;
#end
#end

0 votes
Nelly Le Texier July 11, 2013

Hello,

Is there a workaround for the 5.1 version? Indeed, the function "getFirstValueForKey("1")" returns empty.

Thanks.

0 votes
Frank Adam May 3, 2013

I met an Atlassian person at last year's conference, and here is what he told me:

#if($issue.getCustomFieldValue("customfield_10000"))
#set( $cfValue = $issue.getCustomFieldValue("customfield_10000"))
$cfValue.getFirstValueForNullKey() - $cfValue.getFirstValueForKey("1")
#end
(replace customfield_10000 with an id for your custom field in both spots!).
This worked in JIRA 4.5, but it's not working in 5.2 right now.

Suggest an answer

Log in or Sign up to answer