cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Fry Chef john_hanauer
Fry Chef

How to preserve line breaks from text area fields in SFM Smart Documents?

Jump to solution

It seems that the PDF generator for output/smart documents does not handle line breaks for text area fields. Has anyone found a workaround? I have successfully used javascript to string.replace() line breaks with <br/> tags, but the <br/> tags end up being escaped with HTML entities like &lt; and &gt;

For example, my latest attempt tried to use a DOM model, but it's still escaped on the pdf:

{{(function() { var br = document.createElement('br'); var ret = $F.FORMAT("{0}", $D.Work_Order.SVMXC__Work_Performed__c); return ret.replace(/(?:\r\n|\r|\n)/g,br.outerHTML);} )()}}

Message 1 of 2
0 Likes
1 Solution

Accepted Solutions
Fry Chef john_hanauer
Fry Chef

Re: How to preserve line breaks from text area fields in SFM Smart Documents?

Jump to solution

Got the following response from ServiceMax Technical Support:

In this case it would be best to use the following white-space:pre-wrap, ie. <div style='white-space:pre-wrap'>

Here's an example of it in use: 

<div style='white-space:pre-wrap'>{{$D.Work_Order.SVMXC__Problem_Description__c}}</div>

Message 2 of 2
1 Reply
Fry Chef john_hanauer
Fry Chef

Re: How to preserve line breaks from text area fields in SFM Smart Documents?

Jump to solution

Got the following response from ServiceMax Technical Support:

In this case it would be best to use the following white-space:pre-wrap, ie. <div style='white-space:pre-wrap'>

Here's an example of it in use: 

<div style='white-space:pre-wrap'>{{$D.Work_Order.SVMXC__Problem_Description__c}}</div>

Message 2 of 2