I have never created a Webhook in Zapier and I’m not sure what I’m doing wrong.
Does anyone have an example of a Webhook that is running from a Google Apps Script?
I want to run a function that adds a new row at the top to a sheet . . . when a row is added in a different sheet.
I am adding a new row in sheet ‘rawdata’ via Zapier and when that row is added, I want to run the below function to copy that row to the top of another sheet ‘New Order’.
I’ve tried get and post . . . I’m not getting errors now . . but it isn’t doing anything either.
I’m attaching a copy of the webhook in Zapier.
Any help would be appreciated.
Thanks,
Jan
Function:
function rawDataNewRowToNewOrdersSecondRow() {
const targetRow = 2;
let S = SpreadsheetApp.getActiveSpreadsheet();
let R = S.getSheetByName("rawdata") //.getRange(2,1,S.getSheetByName("rawdata").getLastRow()-1,14).getValues();
let rawDataRange = R.getDataRange();
let rawDataValues = rawDataRange.getValues();
let rawDataLastRow = rawDataRange.getLastRow();
let rawDataLastRowValues = R.getRange(rawDataLastRow, 1, 1, 14).getValues();
let rawDataRowCount = rawDataValues.length;
let rawDataColumnCount = rawDataValuese0].length;
let newOrdersSheet = S.getSheetByName('NEW ORDERS');
let newOrdersRange = newOrdersSheet.getDataRange();
//let newOrdersRange = newOrdersSheet.getRange(1,1,rawDataRowCount,rawDataColumnCount);
let newOrdersLastRow = newOrdersRange.getLastRow();
newOrdersSheet.insertRowBefore(targetRow);
newOrdersSheet.getRange(targetRow, 1, 1, 14).setValues(rawDataLastRowValues)
}