1
votes

I'm having an issue with doing an HTTP Post in the onOpen event in google apps script. What I'm trying to do is send a notification to another deployed script that someone has opened one of our spreadsheets. I'd like this functionality to persist even when someone copies the spreadsheet so that we can track where those are as well.

My problem is that if I call UrlFetchApp.fetch(url, options) from the onOpen event, I get the error - "Execution failed: You do not have permission to call fetch" however the fetch does work if I create a trigger using the ui that fires when the spreadsheet is opened. The problem with this approach is those triggers are not copied when the spreadsheet is copied.

Any suggestions for a possible solution or a simple workaround would be greatly appreciated.

Thanks, Mark.

1
Persisting scripts reminds me of this question & proposed answer. I hope this helps.Jacob Flatter

1 Answers

1
votes

There are two types of triggers - simple and installable. The onOpen is a simple trigger and there are limitations on what you can do within a simple trigger and doing an UrlFetch is one of them. You can read more about simple & installable triggers at https://developers.google.com/apps-script/understanding_triggers