How to trigger a Google Apps Script using Knime?

Hi, I have a google apps script which I access in my GSheet using the dropdowns. Whenever Knime updates my GSheet, I want the attached Apps Script to run exactly once. I tried setting up a trigger in Apps Script but the onEdit trigger works only if the spreadsheet is manually updated. The onChange trigger results in the Apps Script running twice whenever my workflow dumps data into the GSheet. Help?

Hello @nallich,

I believe what you need here is something called ‘debouncing’, or just preventing some funciton from running too much.

I would first try and just adding a simple wait at the beginning of your function for like 30 seconds and check if that fixed the issue. If not, you may need to look into a better method like logging the last time knime wrote to the google sheet and going off of that.

TL

2 Likes

Thank you thor_landstrom, this is a great approach. I shall implement some logic before my apps script function to prevent a double run.

1 Like