Trying to print an address from a Saved Search to ...
# suitescript
a
Trying to print an address from a Saved Search to an Advanced PDF Template and I don’t get break lines… the whole address is one line… I tried:
${result.address_field?replace('\r\n','<br />','r')}
${result.address_field?replace("/\r\n/g","<br />","r")}
Also tried formula text in the related search… with:
REGEXP_REPLACE({address_field}, '/[\r\n]/g','<br />')
REGEXP_REPLACE({address_field}, '/[\r\n]/g','nl')
Still getting the address in one line…
t
@alien4u I've run into that before. Here is what I do to solve that issue: //format address with line breaks var addressArray = (customerAddress.split(/\n/g) || []); var addressArrayCount = addressArray.length; var refinedAddress = ''; for (var ra = 0; ra < addressArrayCount; ra++) { refinedAddress += (addressArray[ra] + "<br\/>"); }
customerAddress is the address I got from the search
refinedAddress is the end result to use in the PDF template
a
I solved that in script before but here is a search directly going to advanced pdf template…
t
ah, got it.
a
I got it working… thanks…
t
Great!
j
@alien4u what was your solution?
a
In the related search a formula text:
TRANSLATE({address_field}, chr(10), '|')
And in the PDF Template:
${result.formulatext?replace("|","<br />")}
I will like to do it only in the PDF template side without needing a formula but I can’t find a way yet…