Skip to main content

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)

}

 

 

 

Hey @Jan at MIH ,

 

I just recently did a very similar project for a client. You can use code from here , you will have to edit a bit as this app scrip triggers on new updates also.

 

If you still face any issue, i will suggest you hire a Zapier expert from directory here (You can hire me also for this project)

 

 


Thank you so much for responding @jayeshkumarbhatia .  I really appreciate the help.
When I try the above . . and several similar things, I have 2 issues.
#1 - When I manually add the record, it adds a new row in the ‘new orders’ sheet for every cell I type.  See screenshot.
#2 - When I add a row using Zapier, nothing happens . . . it doesn’t add the new row into New Orders at all.

The only thing that sort of ‘works’ is when I copy a row and then paste the row in the rawdata sheet . . then I get one row in the neworders sheet.  But that isn’t going to work.  I really need Option #2 above.

I guess I’m going to add a button for the user to push to pull in the latest order instead.  Not ideal -- for sure.  I’ve spent way too much time on this already.

Again, thanks for responding and for being available for hire.  I really appreciate it.

Have a great day!
Jan