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

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

1 Like

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>>
3 Likes

@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.

1 Like

@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.

3 Likes

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

7 Likes

Nice workaround