Email template question - plain text

Hi All,

I created a new template which works great but I have a trouble with a custom field:

I have a custom field called 'Comment for Reporter' which is look like this in the plain text template:

Comment for Reporter: 
$issue.getCustomFieldValue("customfield_10000")

The Comment for Reporter string is the title of the value but the value of the field comes from the code. The problem is that if I don't fill this custom field - so I leave it blank - in the notification email the code string '$issue.getCustomFieldValue("customfield_10000")' appears. What did I miss in the template???

Can you please help?

Thanks a lot in advance!

Rumi

4 answers

1 accepted

This widget could not be displayed.

Try

#if ($issue.getCustomFieldValue("customfield_10000"))
$issue.getCustomFieldValue("customfield_10000")
#end

or

#set ($temp = issue.getCustomFieldValue("customfield_10000") )
#if ($temp)
  $temp
#end

(I'm not sure which is more efficient, I don't know Velocity and Java well enough)

Haha, 47 sec difference, seems we both thought of the same solution :)

The first option works best, especially whent the value concerned is not derived, as data is the computed twice.

The problem with the second option is that with no CF value, the assignment will fail and you will get velocity 'error' noise.

Hi Nic,

don't be modest:)

The first idea was perfect!

Thank you!

Rumi

This widget could not be displayed.

Try

#if ($issue.getCustomFieldValue("customfield_10000"))
$issue.getCustomFieldValue("customfield_10000")
#end

or

#set ($temp = issue.getCustomFieldValue("customfield_10000") )
#if ($temp)
  $temp
#end

(I'm not sure which is more efficient, I don't know Velocity and Java well enough)

This widget could not be displayed.

Try

#if ($issue.getCustomFieldValue("customfield_10000"))
$issue.getCustomFieldValue("customfield_10000")
#end

or

#set ($temp = issue.getCustomFieldValue("customfield_10000") )
#if ($temp)
  $temp
#end

(I'm not sure which is more efficient, I don't know Velocity and Java well enough)

This widget could not be displayed.

Do you have any specific error in the logs? You could maybe fix it like this:

#if ($issue.getCustomFieldValue("customfield_10000"))
    $issue.getCustomFieldValue("customfield_10000")
#end

thank you Dennis!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

110 views 15 7
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