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

1 vote

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

0 vote

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)

0 vote

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)

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

72 views 0 11
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