Ronnie Headen Ronnie Headen - 7 months ago 56
HTML Question

Google Apps Script - Using Sidebar form to append a row to spreadsheet

This script should append a new row to my spreadsheet 'onclick' of the button, however it doesn't. Ultimately I want to be able to add data to each textbox corresponding to a column and append a new row. Not sure why this doesn't work. How do I append a new row? THis script works in the script editor when I run it, just not in the sidebar html.

// Use this code for Google Docs, Forms, or new Sheets.
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.addItem('Open', 'openDialog')



function openDialog() {
var html = HtmlService.createHtmlOutputFromFile("Index");
html.setTitle('Gmf Sent Msg Form');


function insertRow(){
var doc = SpreadsheetApp.openByUrl(" TFhlCyF9TKRk4Hb4b6Q1TnYa5K7ixyktykY/edit#gid=0");
doc.getActiveSheet().appendRow(['700','9/12/16','PO 16-45789'])


Use this form to enter information into the cells of the spreadsheet.<br>
<input type="text" name="txtID" />
<input type="text" name="txtDate"/>
<input type="text" name="txtSub" />
<input type="button" value="Append Row" onclick="
.withSuccessHandler(insertRow)" />


At this line:

<input type="button" value="Append Row" onclick="" />

You're setting the callback function withSuccessHandler() but you're not calling any server-side function, to call it directly you need to use:;

If you want to set the callback function to run if the server-side function returns successfully.;

For more information, see the guide of communicating with server functions and