google apps script - UI to HTML, conversion will not write a date to the sheet -
i trying replicate question posed pieter jaspers regarding conversion of form uiapp html. original question is:
original question pieter jaspars answered sandy good
if replicate code correct result, when try recreate inline form , amalgamate 2 not getting result. inline form question here:
html inline form formatting question answered mogsdad
the code have far in requisite number of parts, form , 2 .gs sheets. have checked spelling mistakes , have tried editing out each line see , get, limited experience drawing blank. minor success if run function insertinss()
within code editor. posts word "undefined" in correct cell in correct spreadsheet, not date trying do!
form:
<!-- use templated html printing scriptlet import common stylesheet. --> <?!= htmlservice.createhtmloutputfromfile('stylesheet').getcontent(); ?> <html> <body> <div> <!-- page header title & 'completion warning --> <span class="grey"><b>proreactive log form v3.0.74</b></span> <h4>complete fields ensure form processed successfully</h4> <div class="block"> <!-- first input box created --> <div class="inline form-group"> <label form="date">date</label> <input type="date" id="date" style="width: 125px;"> </div> </div> </div> <!-- end of fields completion, finish form submission button --> <button class="share" onclick="rungooglescript()">submit</button> </body> </html> <script> function onsuccess(argreturnvalue){ alert('was successful ' +argreturnvalue); //resetfields on screen document.getelementbyid("date").value = ""; } function rungooglescript() { logger.log('v3.0.74 ran!'); var inputvalue = document.getelementbyid("date").value; google.script.run.withsuccesshandler(onsuccess) .insertinss(inputvalue); }; </script>
the code.gs:
function doget(e) { return htmlservice.createtemplatefromfile('myform') .evaluate() .settitle('proreactivelog') .setsandboxmode(htmlservice.sandboxmode.native); };
and seperate.gs:
function insertinss(argpassedinname) { var sskey = '1czuemdriyzifm4lgct20s-wpv27o0hbbzasxd1wjfl8'; var ss = spreadsheetapp.openbyid(sskey); var sheet = ss.getsheetbyname('log'); sheet.getrange(sheet.getlastrow()+1,1,1).setvalue(argpassedinname); }
any ideas going wrong? ever, appreciated.
an apps script html app, not allow date object passed server.
google.script.run parameter documentation
the documentation states:
requests fail if attempt pass date, function, dom element besides form, or other prohibited type, including prohibited types inside objects or arrays.
you need pass date string. convert date string in client side code, , convert date, if need be, in server code. however, if set value in spreadsheet string, may coerced date without needing anything. if have column defined date in spreadsheet.
Comments
Post a Comment