I am trying the following to add line breaks to a message box but it is not working.
function showMsgBox(){
var msg = 'name: \n \n \n Doc URL';
Browser.msgBox("Selected Doc template:", msg, Browser.Buttons.OK);
}
I does not matter single or double quotes.
I also tried Browser.msgBox(msg);
but it is all the same.
What am I doing wrong?
Thank you.
New-line characters ("\n") are converted to line-break characters ("\r").
\n : Apps Script inserts a new line when it encounters a " \n " in the string. The characters that follow a \n will be printed on the next line.
Simple triggers and installable triggers let Apps Script run a function automatically if a certain event occurs. When a trigger fires, Apps Script passes the function an event object as an argument, typically called e . The event object contains information about the context that caused the trigger to fire.
You need to double-escape "\n" for historical reasons
function myFunction() {
Browser.msgBox("Hello\\nWorld")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With