How to write google sheet script so only latest timestamped forms record if duplicate is the only record?

Hi, is there a way to delete all duplicates except the most recent timestamped dupe via google sheets app script? This is so the calcs are using recent numbers for that form record.

Is ‘=unique’ function not enough?

I would probably use a query against the sheet with a MAX and a GROUP BY.

1 Like

Hi Jeff

Thanks for the offers of help! I managed to create my 1st google app script thanks to another post. It needs to automate and keep the google rows slim.

1 Like

How are you getting around the API limitations whereby the edit or change triggers don’t fire unless edited by a human? I was trying to use custom scripting in a sheet for some things but discovered the scripts will not fire if the sheet is edited via API as Glide does.

Not entirely true. You can use the OnChange installable trigger. Anytime that Glide changes the data, the trigger fires allowing anything in the script to be run. I have such an example with one of my apps.

Does it work?! According to google’s documentation, “Script executions and API requests do not cause triggers to run.”

Carlos is right.

Does onChange fire only when the structure changes (i.e. row or col is added as the google docs imply)? Or does it also fire when a row is edited or deleted/cleared out from a user removing that item in glide?

Yes. You can even capture the type of change by using the “(e)” event for the trigger, i.e., “e.changetype” to see if it was an edit or something else.

Look at this…


The syntax that you use in your script to figure out what type of change it is, is
‘if (e.changeType == EDIT){condition if true}’

The OnEdit trigger does not seem to work, unless someone has found a way to make it work with Glide. So, use the OnChange trigger and see how you can make it work for you.