Problem rendering new line for custom field during customization of email html template

I read up

https://confluence.atlassian.com/display/JIRA/Customizing+Email+Content

https://developer.atlassian.com/display/JIRADEV/Adding+Custom+Fields+to+Email

to learn how to customize email html template.

Everything seems to go well except a custome field value with multiple New line which being rendered as single line.

#foreach ($value in $customFieldManager.getCustomFieldObjects($issue))

#set ($eachCustomValue = $issue.getCustomFieldValue($value.getId()))

#set ($chkResult = $stringUtils.contains($eachCustomValue,"\n"))

#set ($chkLength = $stringUtils.length($eachCustomValue))

$eachCustomValue / $chkResult / $chkLength

Verified that the checking of "\n" are false.

Length contain the new line character.

Question:

How to split the line to <br/>? Or is there any better way to handle new line character for custom field value?

I also checked the implementation of Comment and Description Field which the html rendering are being taken care by the JIRA engine.

1 answer

1 accepted

found an article that resolve my problem.

http://raibledesigns.com/rd/entry/replacing_line_breaks_with_html

#set($comments = $comments.replaceAll("\n", "<br />"))

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot