Newline in string varaible


#3

on screen or in a sms thats how paragraph will look. if you output it to log or set to piston state you should see the newline work as expected.


#4

So is there any way I can do what I’m trying to do, insert a special character in a string? Paragraph will be the body of an email.


#5

if you insert paragraph in an email, its not correctly formatting the text with a newline?


#6

It is not, it contains the /n. Same if I use paragraph in a Push notification.


#7

\n wont work for push or sms. for email try \r\n instead of \n


#8

Same result using \r\n or also using just \r.


#9

I guess the question boils down to this: is there another way to insert a control character into a string variable? I Greatly appreciate the help!

Note: I tried this as well…

and here’s a snippet from the email…


#10

we had discussed this at some point on another thread. i am misremembering the conclusion of the thread now.

tagging @webCoRE_Minions to see if someone else remembers.


#11

I’ve usually done a multiline string using the Expression input rather than Value, like this:

'Line 1
Line 2
Line 3'

#12

Well damn if the answer isn’t always the simplest one and right under my nose. First I apologize for wasting everyone’s time, and second thank you very much to all for helping!

Here’s what it looks like:


#13

Certainly not a waste of time! It took me a lot of mashing around with functions and \r \n to realize that multi-line strings work and now this thread is ready for the next person who needs it.


#14

Yeah, using the Enter key in an expression should provide a new line. Also, \r, \n, or \r\n should all translate to a single new line, don’t think there’s a difference between using any of the three. No need for format() just put them like that in a Value field or in an expression string.


#15

So further testing I see the \r\n sure did place a what appears to be a control character into the string looking at the log (I see >> instead of \r\n). But when that string is used in a send email, it shows up as \r\n. Is it possible something converts the control characters back in the email processing? Only sharing this since it appears the expectation is it should work as I had attempted, my code is working fine with the enter inserted.


#16

Hey there, I am trying to put in a page break in an expression to send in an email and I have tried the ENTER key, \r, \n, nothing, I am new to webcore and not sure I am following the logic of @ipaterson, your 'line… expression? Thanks so much!


#17

Do you have an example you are willing to share?

One key that many people miss is to make sure the line break is inside quotes. @ipaterson’s example starts with a single quote before Line 1 and closes with single quote after Line 3 so that the entire text and line breaks are within quotes. ' <ENTER> '


#18

If @fieldsjm’s advice doesn’t work, maybe the email is formatting as HTML rather than plain text. Try <br> to see if that comes through as a line break in the email.


#19

Here is my piston - image - I have tried \n, \r,
. the enter key. I am sure I am missing something simple.


#20

I just tested and the email worked for me (also worked for SMS and push notifications)

(I assumed you are only sending the devicesHigh variable as the body)

Also, just to verify, when setting the deviceHigh variable, your expression should look like the example below, with the Enter after the comma prior to the single quote: (note I used temperature instead of heatingSetpoint)


#21

Thanks. It shows in Webcore that it is working but it is coming through in gmail and Outlook with the \n as text. What email client are you using?


#22

PS - I tried gmail and hotmail with the same results, \n in the text.