Substituting line breaks in email template

In the app, if I was wanting to display a list of items, each item on it’s own line, I would do the little trick of:
substitue([list] , " , " , "
")
Basically, substituting a line break, for every comma.

This does not seem to work in an workflow email template. Does anyone know how I can do this?

Additional related question: How can I insert HTML code into a workflow template? Trying to use angle brackets, <>, results in them being displayed, via HTML code of “&lt” and “&gt”. I’m thinking that I want to substitute an HTML “br” line break for each comma in this specific case.

Edit: funnily enough, HTML br code produces an actual line break in this posting, hah!

Thanks

Solved Solved
0 23 4,645
1 ACCEPTED SOLUTION

Thank you very much for that hint Marc. This was the solution.
I even didn’t need an extra VC.
In my template I added a Table and put in the expression:

<<Start:SELECT(OriginalTable[Key] , IN([Key],[_THISROW].[list]))>><<Label>><<End>>

Now I get a nice Table in my PDF. And by setting the table border to white and 0 pt, I will get just a List with line breaks

View solution in original post

23 REPLIES 23

@Marc_Dillon
May be you can try with: SUBSTITUTE([list] , " , "\n" where \n denotes to a new line

Is your [list] an EnumList column in the same record or a list from another table?

I think I tried “\n”, with no luck.

Yes an EnumList in the same record.

@Marc_Dillon
Are you using a gDoc as a template for workflow email body?

It sounds that the only way you can do this with the template, is an IF expression like…

<<If:ISNOTBLANK(INDEX([EnumList],1))>> <<INDEX([EnumList],1)>> <<EndIf>>
<<If:ISNOTBLANK(INDEX([EnumList],2))>> <<INDEX([EnumList],2)>> <<EndIf>>

@Marc_Dillon
I haven’t tested it with a gDoc body template however below solution works if you use the email body property of the workflow rule. You are free to copy the app from my portfolio > https://www.appsheet.com/portfolio/245151

Just choose your name from Home screen and either edit the existing record or add a new one and enter your email address to receive the result.

Thanks guys,

Levent. I have a whole big complicated template that I’m not going to convert to HTML code in the Email Body field. So I guess this won’t work for me, but thanks for the effort! One question though; why do you split() the list inside of the substitute()?

Aleksi,
I think I’m going to have to do this. The length of the list is indeterminate though so I suppose I’ll just have to guess and overshoot. Messy, but good idea.

These are onedrive documents by the way, doesn’t look like it really matters though.

Adding @Phil
I’m having the same problem. I want to use

substitue([list] , " , " , "
")

in a workflow template but it doesn’t work.

@Fabian, as stated above, this apparently doesn’t work in workflow templates. You’ll have to use either Aleksi’s isnotblank(index(… suggestion, or Levent’s suggestion about hand-writing the template in the email body property.

In what way doesn’t it work?

In a workflow template (Google Doc) it will not create Newlines from an EnumList as it does in the App, for example in a detail view.

Does it remove the commas?

Yes it will remove the commas but will not create newlines.

In the detail view it looks like this:

Selection1
Selection2
Selection3

In the PDF created by the workflow it looks like this:

Selection1 Selection2 Selection3

Let’s see what Mr Workflow will think about this. It’s the same for the , separator as well on template.

@Phil Any input?

There is no provided mechanism for inserting line breaks in a template.
Aleksi’s approach is the only one that I know of.

If you have the ability to convert your list to a list of row refs, then do so in a VC, then use a start expression in the template on that VC.

Thank you very much for that hint Marc. This was the solution.
I even didn’t need an extra VC.
In my template I added a Table and put in the expression:

<<Start:SELECT(OriginalTable[Key] , IN([Key],[_THISROW].[list]))>><<Label>><<End>>

Now I get a nice Table in my PDF. And by setting the table border to white and 0 pt, I will get just a List with line breaks

Nice workaround

Oh wow. Yah that’s great.

Does anyone have an example app? Tried the solution presented above and still can’t get it to work.

PgM
Bronze 3
Bronze 3

Hello All, 

 

Does anyone could make it work with Gdoc ?

here is the initial value of my enumlist named [Proposition]:

- Communication via catalogue , - Rédaction article Blog , - Communication RS , -
Communication via mailing

I tried this code <<SUBSTITUTE(SPLIT([Proposition]," , ")," , ","<br>")>> in mygdoc template and no breakline have been added in the output

- Communication via catalogue<br>- Rédaction article Blog<br>- Communication RS<br>-
Communication via mailing

Where it works in the Email Body

- Communication via catalogue
- Rédaction article Blog
- Communication RS
- Communication via mailing
 
Any help/support would be greatly appreciated 😉
 
Thanks
 
PG

I just had this situation where I need to display multiple optional columns on separate rows in a PDF report, and finally solved it.

The solution is to create a virtual column in the table, of type LongText, and populate it using an expression that concatenates the column values with LineFeeds. The LongText data type along with its line feeds is preserved when outputting to a template.

In my case I have a required and some optional columns:

Car Number 2, Car Number 3, Car Number 4, Car Number 5, Car Number 6

The virtual column's [Car Number List] expression is:

CONCATENATE(
[Car Number 2],
IF(ISBLANK([Car Number 3]),"",CONCATENATE("
", [Car Number 3])),
IF(ISBLANK([Car Number 4]),"",CONCATENATE("
", [Car Number 4])),
IF(ISBLANK([Car Number 5]),"",CONCATENATE("
", [Car Number 5])),
IF(ISBLANK([Car Number 6]),"",CONCATENATE("
", [Car Number 6]))
)

The template expression <<Car Number List>> outputs the columns that have data as:
123
456
789
012

as if I did a PIVOT of the columns

 

Top Labels in this Space