Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script e.namedValues format multiple choice

I have a simple script that emails the results of a Google Drive form submission. One of the questions in the form has multiple choice checkboxes. I am using e.namedValues to grab the array of answers so that I can email them, like this:

var multiple = e.namedValues['Multiple Choice Question'].toString();

And the result that gets emailed is this:

Answer 1, Answer 2, Answer 3

But I would like the result to be formatted like this:

Answer 1
Answer 2
Answer 3

Instead of separated by commas. Is there any way to do this?

like image 353
user1721009 Avatar asked May 30 '26 05:05

user1721009


1 Answers

Use JavaScript String's split function

var multiple = e.namedValues['Multiple Choice Question'].toString();
var choicesSelected = multiple.split(',');
multiple =''; 
for(var i in choicesSelected){
  multiple += choicesSelected[i] + '\n' ;
}
for (var i in multiple){
  Logger.log(multiple[i]);
}
like image 70
Srik Avatar answered Jun 01 '26 20:06

Srik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!