Hi, everyone. I am hoping to use this to basically emulate a physical form that we use at work now. I would love to be able to add several rows at a time on a form submit. Is this something that I can do now with the project as it is written? If so, can someone direct me to that information? Otherwise, any suggestions for how to make this happen? I am finding the google sheets documentation a little cryptic.
Thanks!
function test() {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(['one cel', 'second cel', 'etc']);
}
appendRow also has another interesting characteristic, it's concurrent-safe. Which means it can be triggered multiple times in parallel and won't mess up. If you want to implement your own function concurrent safe you have to lock it, like this:
function insertRow(sheet, rowData, optIndex) {
var lock = LockService.getScriptLock();
lock.waitLock(30000);
try {
var index = optIndex || 1;
sheet.insertRowBefore(index).getRange(index, 1, 1, rowData.length).setValues([rowData]);
SpreadsheetApp.flush();
} finally {
lock.releaseLock();
}
}
don't forget to retrieve your POST or GET datas with doPost() or doGet() native functions
This is great! Thank you so much.
Most helpful comment
This is great! Thank you so much.