google apps script - How can i load an image in to a template doc based on information submitted in to a sheet from a form? -


basically trying accomplish create contact , image card each of students. have them fill in survey created google forms. when form submitted app script grabs doc template, fills in of information sheet correct place creates doc , pdf , emails them me. still need pull image drive folder (or other location if drive issue , have read in other posts) labeled student id's (ex. 588305.jpg) , insert doc. provide student id's in survey available in sheet t match. attached links sheet, template,and code.

sheet

template

    var doctemplate = "1kuvjc68grazp_8msj_evj8uaylmyt0vu2eu44mbn3fa"; var docname = "student profile template"; function onformsubmit(e) {    var email1 = "sbrumbaugh@piperschools.us";   var last = e.values[3];   var first = e.values[4];   var nick = e.values[5];   var grade = e.values[17];   var gender = e.values[10];   var birthday = e.values[9];   var student_email = e.values[6];   var student_phone = e.values[7];   var student_id = e.values[8];   var w1 = e.values[32];   var o1t = e.values[33];   var w2 = e.values[34];   var o2t = e.values[35];   var w3 = e.values[36];   var o3t = e.values[37];   var w4 = e.values[38];   var o4t = e.values[39];   var p1 = e.values[24];   var i1t = e.values[25];   var p2 = e.values[26];   var i2t = e.values[27];   var p3 = e.values[28];   var i3t = e.values[29];   var p4 = e.values[30];   var i4t = e.values[31];   var seminar = e.values[23];   var parent_first = e.values[13];   var parent_last = e.values[14];   var parent_phone = e.values[15];   var parent_email = e.values[16];   var win_user = e.values[40];   var schoology_user = e.values[41];   var schoology_pass = e.values[42];   var autodesk_user = e.values[47];   var autodesk_pass = e.values[48];  var copyid = driveapp.getfilebyid(doctemplate) .makecopy(docname+' '+last +', ' +first) .getid();  var copydoc = documentapp.openbyid(copyid);  var copybody = copydoc.getactivesection();    copybody.replacetext('keyfirstname', first);   copybody.replacetext('keylastname', last);   copybody.replacetext('keynickname', nick);   copybody.replacetext('keygradelevel', grade);   copybody.replacetext('keygender', gender);   copybody.replacetext('keybirthday', birthday);   copybody.replacetext('keystudentemail', student_email);   copybody.replacetext('keycell', student_phone);   copybody.replacetext('keyw1', w1);   copybody.replacetext('keyw2', w2);   copybody.replacetext('keyw3', w3);   copybody.replacetext('keyw4', w4);   copybody.replacetext('keyo1t', o1t);   copybody.replacetext('keyo2t', o2t);   copybody.replacetext('keyo3t', o3t);   copybody.replacetext('keyo4t', o4t);     copybody.replacetext('keyp1', p1);   copybody.replacetext('keyp2', p2);   copybody.replacetext('keyp3', p3);   copybody.replacetext('keyp4', p4);   copybody.replacetext('keyi1t', i1t);   copybody.replacetext('keyi2t', i2t);   copybody.replacetext('keyi3t', i3t);   copybody.replacetext('keyi4t', i4t);   copybody.replacetext('keyseminar', seminar);   copybody.replacetext('keyidnumber', student_id);   copybody.replacetext('keypgfirst', parent_first);   copybody.replacetext('keypglast', parent_last);   copybody.replacetext('keypgemail', parent_email);   copybody.replacetext('keypgphone', parent_phone);   copybody.replacetext('keywin', win_user);   copybody.replacetext('keyschoologyuser', schoology_user);   copybody.replacetext('keyschoologypass', schoology_pass);   copybody.replacetext('keyautodeskuser', autodesk_user);   copybody.replacetext('keyautodeskpass', autodesk_pass);   copydoc.saveandclose();  var pdf = driveapp.getfilebyid(copyid).getas("application/pdf");  var subject = "student profile template"; var body = "student profile template " + last +', ' +first + " " + "https://docs.google.com/document/d/" + copyid; mailapp.sendemail(email1, subject, body, {htmlbody: body, attachments: pdf});    driveapp.getfilebyid(copyid).settrashed(false);    } 

thanks can provide.

stephan

google forms don't support file upload. found script amit agarwal work: http://ctrlq.org/code/19747-google-forms-upload-files

you have rewrite google form html, luck !


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -