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

Accepted Answer
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 votes

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 votes

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
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

138 views 6 8
View post

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