N'yoma Diamond
N'yoma Diamond

Reputation: 136

How to use a line break in an alert/prompt dialog in Google Apps Script?

I have been having trouble with formatting a dialog in Google Apps Script. I would like to have a dialog using SpreadsheetApp.getUi().alert(prompt) which has a line break so I can have a list. I tried using \n, \\n, and <br />, but nothing appears to work and I can't find anything anywhere on whether or not it is even possible. Any ideas?

Upvotes: 7

Views: 6237

Answers (2)

jaredcohe
jaredcohe

Reputation: 398

I went through this same problem. This actually works:

\r\n

Upvotes: 13

Steve Gon
Steve Gon

Reputation: 462

I have implemented this type of messaging inside a Google doc using the following code:

var doc = DocumentApp.openById('your long doc ID');
var body = doc.getBody();
body.appendParagraph("Line 1");
body.appendParagraph("Line 2");

or you could do it in a sheet using:

sheet.appendRow(['line1col1','col2']);
sheet.appendRow(['line2col1','col2']);

Upvotes: 0

Related Questions