With the help of Moe’s instructions in this article, I was able to create a Google script that adds a new line to my Google Sheet each time a record is added to my Tadabase table.
Now I would like to use the Update Record event option in Webhooks to update the corresponding line in my Google Sheets when a record is updated in Tadabase instead of appending a new line with the updated record.
I am using the Tadabase record ID as the first export field, so it should be easy to identify the unique record that needs to be updated. What Google Script commands would I need to use to identify and update the row in the sheet?
@tim.young I have looked briefly at Integromat and probably should explore it more.
I came up with a workaround. I found a Google script I used several years ago that takes the last instance of an array for each item in a list. So I can put new records and updated records into one tab (named “Import”) in my Google Sheet, and then use this formula in cell A2 in another tab:
This assumes I have a header row that I want to skip, and I want columns A thru O.
Here is the script for the LastArrrayRow function:
/**
This function returns the last instance of an array for each item in the first column based on the second column.
*/
function LastArrayRow® {
var d={};
for (var i=0;i<r.length;i++) {
d[r[i][0]]=i
}
var a=[];
for (i in d) {
a.push(r[d[i]]);
}
return a;
}