Google Sheets: installable trigger seems to disable simple trigger script - google-apps-script

I have a Google sheet with a function that enters a timestamp in a column if the column to its left is updated. It is triggered by the simple onedit trigger, and it only processes for a small set of cells in the sheet. It has worked fine for months with many people.
Then I added a script to do some data cleanup on a separate tab of the same doc. I use an installable trigger, so that I can schedule the cleanup to run once each week.
Unfortunately, while the scheduled installable trigger cleanup routine now works, the original onedit simple trigger timestamp routine does not. To be more precise, the timestamp routine works for me, the author of the script, but it does not work for anyone else.
Any idea how to address this?
Thank you!

the timestamp routine works for me, the author of the script, but it does not work for anyone else.
Issue can be found in Stackdriver logs. Go to Script Editor>View> Executions>Clear all filters. Check the failed logs. Most possible reason is You restricted access to those people. If the "user at the keyboard" is not permitted to do something manually, He cannot do that through scripts either. Another possible reason is Anonymous edits cannot show popups/dialogs; If you added such code to your function, Your function will fail.
Possible Solution(s):
Provide the necessary permission or
Create a installable onEdit trigger, so that the function will run under your authority. In this case, if editors are able to access your editor, they may be able to execute scripts as you. Protecting all sheets with unprotected ranges may help this, but does not provide complete security. Reducing authorised access scope might also help
Another way to do this is by creating a service account and use oauth library to access the sheet.Sample here and here.

Related

Apps script authorization for openId don't work with onEdit(e) trigger

I have a problem with a google sheet script, I would like to transfer data from one workbook to another using an onEdit trigger, but when my trigger fires, I have a message of error in the execution log which says that I do not have the authorizations to access this file, however when I do the same action but without trigger (by activating the function by hand) it works without problem. I don't know at all where the problem comes from, if someone can help me it would be really appreciated because I'm desperate (I found absolutely nothing on google after hours of research), thank you in advance for your help and have a nice day.
Joseph Menard
(PS; I am attaching a link to a video of my screen showing my problem ;
https://www.loom.com/share/f1a0fde043f74143b7caad78ae806be6 )
I assume you are using a simple onEdit trigger? Simple triggers run without authorisation from the user and are subject to several restrictions. Instead ty using an installable onEdit trigger and see if that helps?

Script always active

Sorry if this was asked before but I could not find then answer.
I created a spreadsheet that is used by many users. It has an onEdit script. However it only works for me. Does every single user has to accept access for the script to change the spreadsheet?
The script will be run by and have the permissions of the owner that created the trigger to the script.
Ie if your account created the simple or installable trigger and steve opens the sheet, his actions will trigger the script to be run by your account.
None clear behavior that I have noticed that might explain what you are seeing:
- if lets say bob only has read only access or comment only access to the spread sheet no triggers will fire for his instance ( ie onopen() ).
Feel free to attach your full or a snippet of your code and trigger settings and someone should be able to assist in debugging.

Scan-IT to Sheets trigger

I am using the Add-on Scan-IT to Sheets to input inventory info - I need the function I have coded to run after every scan. The problem is, when the scan is populated to the sheet it does not trigger the onEdit or onChange.
Any advice is greatly appreciated!
No trigger activates with a change made by a script or addon. As you can read on Triggers Restrictions: «Script executions and API requests do not cause triggers to run». So, it is not possible to use them in your situation.
As a workaround you can use time triggers to run your function, or just run them manually.

Apps Script Making onEdit and onOpen triggers work only for the current user

Probably the answer to this is simple but I am having a tough time getting my head around it.
I have a spreadsheet used by many users. I want custom onEdit and onOpen functions to run only for the user who triggers then. For example - if person B opens the spreadsheet, then only his custom onOpen trigger should run, not the custom onOpen triggers for the other users. Likewise if the user edits a cell only his custom onEdit should run.
Currently how I have set it up everyone has his own triggers but they all run the same script every time there is a trigger by any user, meaning the trigger runs 4x for no reason and it's slowing down the spreadsheet, and it also wastes script time usage for the other users who are not opening or editing the sheet.
You can have separate functions for each user and have code dynamically check for current user and run the function of current user only.
See here for getting current user. Link
Assuming the functions are the same but you just aren't wanting it to run for some users, you could use PropertiesService to store a user property to identify if it should run or not. You have to make some UI method to set the property and then you would check for the property at the beginning of each of your functions. Technically the functions would run but you could return out of them if you don't want to finish the logic.

Google Apps Script onEdit() trigger not executing

I have been implementing a spreadsheet for about a year and a half now that constantly runs a number of trigger based GAS functions to check data, send emails based on that data, and update a staff calendar.
All of the time driven triggers are executing normally. I have not had an issue with them. However, the spreadsheet driven triggers (onEdit, onChange) are not working at all. I left work for a two week vacation and I did not change the script at all. When I came back, it no longer worked.
I deleted the trigger, recreated it, and switched between onEdit and onChange; the trigger will still not fire. The function that is triggered on edit is dependent on the event for it to execute properly. I test ran the function outside of the trigger and it failed where I expected it to (where the event dependant variables are) so there was no surprise there.
As far as I can tell, the spreadsheet driven triggers just won't fire at all. Does anyone know of any issues on Google's end, are spreadsheet driven triggers working for any of you guys? As far as I can tell the trigger just stopped working all together.
If I explicitly nest my function inside the onEdit() function in the script, it will execute, it won't if I just create a trigger, however it throws an error saying that the script does not have the permissions to execute MailApp.sendEmail() even though the app is already authorized to send emails as me.
Even more interesting, the functions executed with time driven triggers are still able to send emails and update my calendar.
It seems like the spreadsheet driven triggers have quit working all together.
Just to be clear I did not make the mistake of naming my function onEdit or onChange.