How to add a new line in google forms paragraph type question
For adding new line in google form question multiple choice question, add the following code in script editor:
Code:
function addLineBreaks()
{
var form = FormApp.getActiveForm();
// find form items you need
var questions = form.getItems(FormApp.ItemType.PARAGRAPH_TEXT);
for(i = 0; i < questions.length; i++)
{
var title = questions[i].getTitle();
questions[i].setTitle(title.split(". ").join("\n"));
}
}
Thank you very much. That worked. I used the change suggested in the YouTube comments of replacing title.split(". ") with title.split("*") so that I can add line breaks only at those places where I want them, and have typed a "*".
ReplyDeleteGlad to know it helped...
DeleteHi! I've tried the code. But I am confuse as I always get "SyntaxError: Invalid or unexpected token (line 14, file "Code.gs")" everytime I save the code. Pls help, thanks
ReplyDeleteLooks like there will be some syntax error. Can you please copy the code here..
Delete