Line Breaks Not Recognized in Google Script -


i making form , line breaks not working, makes returned information more difficult read.

i realized started happening after added replyto mailapp, cannot find way fix problem. tried \n , \r.

any suggestions?

    function initialize() {    var triggers = scriptapp.getprojecttriggers();    for(var in triggers) {     scriptapp.deletetrigger(triggers[i]);   }    scriptapp.newtrigger("sendgoogleform")   .forspreadsheet(spreadsheetapp.getactivespreadsheet())   .onformsubmit()   .create();  }  function sendgoogleform(e)  {     try    {           // personal info     var timestamp = e.values[0];     var username = e.values[1];     var phone = e.values[3];     var preferredcontact = e.values[5];     var affliation = e.values[6];     var articleorbook =e.values[7];     var itemfrom = e.values[8];     var deliverto = e.values[9];      // emails     var email = "interlibraryloan@holyfamily.edu";     var useremail = e.values[4];      //book values     var book = e.values[18];     var bookauthor = e.values[19];     var publisher = e.values[20];     var year = e.values[21];     var isbn = e.values[22];     var edition = e.values[23];      //article values     var article = e.values[10];     var articleauthor = e.values[11];     var journal = e.values[12];     var volume = e.values[13];     var issue = e.values[14];     var date = e.values[15];     var pages = e.values[16];      // optional change following variable     // have custom subject google form email notifications     var subject = "interlibrary loan request submitted";      var s = spreadsheetapp.getactivesheet();     var columns = s.getrange(1,1,1,s.getlastcolumn()).getvalues()[0];         var message = "";      var usermessage = "dear " + username + ", \n\nthank submitting intercampus/interlibrary loan request. notify when \n\n" + book + article + " " + bookauthor + articleauthor + "\n\n available. \n\nintercampus or interlibrary loan service \ninterlibraryloan@holyfamily.edu \nholy family university \n267-341-3584";          // include form fields not blank     ( var keys in columns ) {       var key = columns[keys];       if ( e.namedvalues[key] && (e.namedvalues[key] != "") ) {         message += key + ' :: '+ e.namedvalues[key] + "\n\n";        }     }      // mailapp service of google apps script     // sends email. can use gmailapp html mail.      mailapp.sendemail(email, useremail, subject, message);     mailapp.sendemail(useremail, email, subject, usermessage);    } catch (e) {     logger.log(e.tostring());   }  } 

there seem issues character not being preserved, though escaping seems have been @ least partway fixed.

if going formula bar, want use "hello"&char(10)&"world!" newline.

otherwise can use paragraphs instead:

 var body = documentapp.getactivedocument().getbody();   // append document header paragraph.  var header = body.appendparagraph("a document");  header.setheading(documentapp.paragraphheading.heading1);   // append section header paragraph.  var section = body.appendparagraph("section 1");  section.setheading(documentapp.paragraphheading.heading2);   // append regular paragraph.  body.appendparagraph("this typical paragraph."); 

this useful when viewing output in html since browser tend eliminate white-space, paragraph understood functionality want.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -