Team,
I have below code :
a!localVariables( local!data1:{"test1<br>","test2<br>"}, local!data1)
Output is list of text strings
I want the output to be in format "tetst1<br>test2<br>"
Basically i am formatting a data before sending into email template but it is appearing like below , i want the semicolon to be removed.
Test1 ; Test2
It should be like below
Test1 Test2
ANy suggestions ?
Discussion posts and replies are publicly visible
a!localVariables( local!data1:{"test1<br>", "test2<br>"}, joinArray(local!data1, char(10)) )
will result in:
test1<br>test2<br>
To get rid of the HTML break tags you will need to do a subsequent line-by-line command such as stripHtml(), though I don't presume to know exactly what you're hoping to have happen with HTML formatting in your input text. FYI appian won't format HTML as rich text without some pretty significant user-defined parsing, etc, which gets pretty complicated to set up.
In answer to your first question you can use fn!joinarray():
fn!joinarray( a!localVariables( local!data1: { "test1<br>", "test2<br>" }, local!data1 ) )
If you want to have the output actually on separate lines (as is indicated by your second question) then you can loop through your input items and append a "new line" Unicode character to all items except the last item:
a!localVariables( local!myList: { "Test1", "Test 2", "Test 3" }, local!myResult: fn!joinarray( a!forEach( items: local!myList, expression: if( fv!isLast, fv!item, concat(fv!item, char(10)) ) ) ), { a!paragraphField(value: local!myResult) } )
Maybe it's just me, but this seems like a lot of extra run-around compared to `joinarray(local!list, char(10))` which is equivalent.
joinarray(local!list, char(10))
You'll get an extra char(10) in your code, which, in the scheme of things, may not be a big deal. I was trying to provide illustrations, not definitive solutions.
...actually, I take that back - joinarray() only inserts the separator between the elements of the array, so no extra char(10) at the end...so yours is indeed the less verbose solution.
yeah, any extra complexity and you need to know how to do a!forEach() with use of fv!isLast (etc), though for this case I felt like that was putting the cart before the horse a bit ;-)
Thank you , It worked.
Thank you.