app script OnEdit function not working when document is copied

Viewed 13

I built a google sheets automation with AppScript. The main function is an onEdit function.

I need other people to 'make a copy' of the entire document to run on their computers.

When someone makes a copy of the document, they are not triggered to approve the appScript code and the onEdit function (and other functions) do not respond.

I have to go into the appScrip editor on their computers and manually run one of the functions to trigger the approval dialog. Even then, the onEdit function doesn't seem to work.

Here is the document for your trial: https://docs.google.com/spreadsheets/d/12ZE1QzyQ45GB6BtEIetKU4uHVG6rZrs2LVlvT36PnQE/edit?usp=sharing

Please make a copy of the document and add the following data in this order. Cell A4: TEST Cell B4: 0 Cell C4: Snack Cell D4: 0

The onEdit function should be triggered and move the data to the table below.

Is there a way to streamline the appScript approval process?

Thanks!

1 Answers

this is not how scripts work. every (most of them) script is by default considered by google as "malicious" and requires users to authorize the script so if something bad happens the user is to be blamed for running the malicious code knowing the risk and not google. in other words, if you create a script it will be attached to the spreadsheet so whoever creates a copy he will copy the script too but then that user needs to go to the script editor and authorize the code for a given account. if you mean no harm with your script and want to share it, google's logic is to pack that script into an addon and publish it. after it will be verified by them as safe, this addon will be available on their platform ready to be installed by other users without those scary WARNING windowses.

Related