Custom field in email shows in 1 line when using HTML

orenkatz January 27, 2013

Hi,

When using HTML email notification the custom filed that I added shows in 1 line, for example:

1. oren
2. test

Will be shown has:

1.oren 2.test

How can I fix it?

I'm using this to show the text:

$issue.getCustomFieldValue("customfield_13188")

Thanks,

Oren.

2 answers

1 accepted

0 votes
Answer accepted
Renjith Pillai
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.
January 27, 2013

Just try the following (I have not tried it myself):

$textUtils.htmlEncode($issue.getCustomFieldValue("customfield_13188"))

And may be use $textUtils.hyperlink as well

orenkatz January 28, 2013

Thanks but didn't work still the same,

When looking at the code of the email I receive it looks like:

<br>

oren

katz

asdf

<br>

But it will shows as "oren katz asdf" because there's no <BR> after each word.

It's driving my crazy :)

Renjith Pillai
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.
February 2, 2013

$issue.getCustomFieldValue().replaceAll("\n","<br/>")

I am guessing that the free text field has \n for newlines.

orenkatz February 2, 2013

$issue.getCustomFieldValue("customfield_13188").replaceAll("\n","<br />") works!!!

Thank you very much! and thank you Matthew as well!

Oren.

0 votes
MatthewC
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.
January 27, 2013

you've marked your question as being an OnDemand query but that is a restricted function in OnDemand?

http://confluence.atlassian.com/display/AOD/Restricted+Functions+in+Atlassian+OnDemand#RestrictedFunctionsinAtlassianOnDemand-JIRA

The procedure for customising email content sent in notification messages requires editing Velocity files within the JIRA webapp. This makes it a special case of "customising source files". See JST-1791 and JRA-7266 for feature requests to allow customisation of email contents through the web UI.

Email will do one line for field, that is their expected behaviour.

where are you using $issue.getCustomFieldValue("customfield_13188")?

orenkatz January 27, 2013

Sorry I ment On Premise - installed on my server.

I'm editing issuecreated.vm under classes/templates/email/html

You can see in the pic I've added "Root Cause" but it should be:

"
Root Cause: dsad
fgghhg
123
oren
"

and not:

"Root Cause: dsad fgghhg 123 oren"

Just like "Description"

MatthewC
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.
January 27, 2013

This is untested but it's cut & paste from something similar, try it with caution & you will have to debug it

#if ($issue.getCustomFieldValue("customfield_13188"))
        #set ($optionList = $issue.getCustomFieldValue("customfield_13188"))
       &lt;table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%"&gt;
        #foreach ($val in $optionList)
            &lt;tr&gt;&lt;td&gt;$val&lt;/td&gt;&lt;/tr&gt;
        #end
       &lt;/table&gt;
#end

I'm assuming your CF is returning a List object, if it's not then this won't work.

orenkatz January 28, 2013

Thanks but is doesn't show anything

MatthewC
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.
January 28, 2013

what's the type of your custom field?

orenkatz January 28, 2013

Free Text Field (unlimited text)

MatthewC
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.
January 28, 2013

Well that explains why mine would not work, I assumed you were using a multi select as you data looked like a structured list.... back to the drawing board. #mustnotmakeassumptions

Suggest an answer

Log in or Sign up to answer