Dynamic New Line

Im having an issue with the event node in workflows


image

creating an event with a \n in it does not escape to a new line but for some reason create a single space in the actual event

although you can manually add newlines in the message box of the event node and that works


There are two things going on:

  1. Browsers do not interpret \n as a newline. So while your message may include a newline character, it will not be rendered.

  2. The Message Template field on the Create Event Node supports Markdown. Behind the scenes, your sections of text are converted to HTML paragraph tags, which are then correctly rendered by the browser on different lines.

To get a line break in the resulting event, I recommend using the Create Event Node and using the Markdown Line Break syntax to get your newlines (two or more spaces at the end of a line).

Ill have to see how it looks once I get some data coming through but thank you!

So im back because it doesnt seem to have worked
image

in the message in the payload you can see it has two spaces in it (one is highlighted and one is not)
however when it renders it doesnt include a new line and only displays one space
image

image

in the html of the page it does display as two spaces

I can’t tell from your screenshots where you’re viewing the description, but here’s a test event I created and what it looks like when viewing the result:

I highlighted the two spaces at the end of the first line.

And here’s the Event when viewed in the platform:

The entered text for the description is entirely from the payload


image

the message on the event node response mirrors the inclusion of two space

and so does the html

but the actual box does not

I see. You’re viewing in CPF. What’s stored on the event is exactly what was typed in the field. The platform UI passes that through a markdown renderer when it’s displayed. CPF does not. We had not considered markdown when creating the CPF. It would be a good feature to add.

You’ll have to now switch to putting HTML in the Event Create Node and making a slight change to the CPF so that your HTML is not escaped.

Then edit the Experience Page cpf-page-event-details and modify line 79 (the exact line number may be different on your version).

Old line:

<div class="mb-2"><strong>Message:</strong><br>{{pageData.event.message}}</div>

New line:

<div class="mb-2"><strong>Message:</strong><br>{{{pageData.event.message}}}</div>

The only change is to surround pageData.event.message with triple curly braces (instead of double curly braces). That tells Handlebars to not escape any HTML in finds in that value. More details on Handlebars escaping can be found here.

perfect! Thanks
image