Google Apps Script keeps running after trigger removed (multiple users) - google-apps-script

I have a fairly simple Google Apps Script that runs every time an answer to a Google Form is submitted (by using "on form submit" trigger). The script does some simple manipulations and updates a Google SpreadSheet. Recently I needed to change that script to run manually and not on form submit, so I deleted the trigger. However the script still kept running on every form submit!
There are other users who might have the same trigger setup, since the spreadsheet and the code are shared. Is there a way to completely delete all the triggers for a particular script? In the meantime I just renamed the script and that has solved the issue, however this is a bad solution.
Search on stackoverflow did nothing, seemingly similar questions are resolved through clearing "Resources -> All your triggers...", which only does it for your user. Question is how to remove/edit all the triggers for the project, even from other users.

Here's how to stop any orphaned Google Script.
Go to https://security.google.com/settings/security/permissions
Click the script / project name you wish to uninstall
Next click Remove and you are done.

Related

Too many time based triggers in Google Apps Script

I have a published add-on on the Google Workspace Marketplace. Suddenly users have started getting the error
This add-on has created too many time-based triggers in this document
for this Google user account.
However, when I have the add-on log what triggers are installed, there are only three, and only one of them is time-based.
What I've started noticing, though, is in the master script file (the one I edit and then publish), when I look at triggers, there are a large number of triggers that are listed as being installed by "Other User." To be clear, there are no shared users on this spreadsheet or the script attached to it. Are these "Other User" triggers coming from users of the add-on?
Otherwise, I don't know what the above error would be referring to. But I also don't understand why the triggers for every user of the add-on would install in the master script.
I also went in and editing the code where the triggers are installed for each user to FIRST delete all instances of that trigger before installing it - same error.
I went a step further and made a button just to delete every single trigger - same error.
From the documentation:
Each add-on can only have one trigger of each type, per user, per document. For instance, in a given spreadsheet, a given user can only have one edit trigger, although the user could also have a form-submit trigger or a time-driven trigger in the same spreadsheet. A different user with access to the same spreadsheet could have their own separate set of triggers.
You may want to create any triggers you need in the onInstall(e) function so that they only get created once. That way, you do not need to delete and recreate the triggers every time the add-on runs.

create Google Sheet database accessed by different users

I've built a spreadsheet as a form by google script with one button which updates a database(a different sheet) according to the form - btn_pressed().
I want to authorize any google account I give access to - to use the form (activate the google script code), and update the database and send mail (part of the btn_pressed() process).
should I publish the script as a web app? or there's another way to do what I'm looking for
I understand that you want to automatically authorise the script for other users when they come to run the script?
I recently learnt you can only do this with certain triggers such as onOpen() out onEdit(), there is a way round this though. Please see the following link as i asked the question on here myself!
Remove authorisation required for script on Google sheets
I trust that helps

Google script trigger 'from Spreadsheet' not available

I've successfully created picklists from a Google sheet into a Google form following a tutorial (http://wafflebytes.blogspot.com/2016/10/google-script-create-drop-down-list.html) and Google's documentation, however I do not have the option to set a trigger on the Event 'From spreadsheet', as laid out in the the tutorials/documentation, so I must be missing a step and haven't been able to figure out what it is.
The result is that the options are not automatically updating and must be manually pushed. I would like to enable the options to be refreshed on open.
I do not have the option to updateForm + from spreadsheet, as pictured in those resources.
From tutorial
My options
What step am I missing? Or is this possibly a permissions issue (I am not owner of the documents, but I tried to reproduce this in docs I own and ran into the same issue)?
NOTE: I have not posted my script here because it's nearly identical to the one linked to in the tutorial.
Update:
I'm beginning more and more to think it has to do with our OAuth configurations or permissions. I even updated the manifest to explicitly authorize forms and sheets, but I'm still not offered sharing permissions. I will have our admin check in on this but if anybody has had experience in these matters, I'm all ears.
Since your options shows "From form", you are working on a project bounded to a form instead of the one that you created from your spreadsheet which is the one bounded to spreadsheet.
Rather than missing a tutorial step it could be that you had several script projects open at the same time and you are looking at the wrong one.
Reference
Event Objects

Google Script Error: You do not have permission to call openById

I am trying to send a mail with attaching a file available in my google drive using following google scripts
var file=DriveApp.getFileById('1qZVK0UZ1jLbDdj10FXZqeAVEodvxEy2Bs');
MailApp.sendEmail('xyz#gmail.com','subject','body',{attachments[file.getAs(MimeType.PDF)]});
when I run above script manually it runs fine, email gets sent. But when I run it using form Submission trigger it gives error "You do not have permission to call openById"
steps that will reproduce the problem?
create a google form.
write above scripts on script editor and add a trigger with submission of the form.
fill and submit the form then you will get above error into mail from 'apps-scripts-notifications#google.com'
Please help.
I ran into this same issue, but felt it was a little silly to have to use the FormResponses Sheet to get the submission event (I mean there's a trigger on the Form Apps Scripts for a reason, right?).
All I had to do was to Remove and Re-add the trigger for From form --> On form submit. When I added it, challenged me for OAuth permissions to view and use my google drive.
Immediately after this, I was able to run on a Forms Apps Script Submission trigger again.
I found this when creating the script on the Form itself.
To solve the problem first have you form responses sent to a spreadsheet.
From you form go to Tools > Script editor... copy you script and delete any triggers you have set up there, you won't be needing this script anymore.
Now click on View responses button in your form to open the spreadsheet.
Go to Tools > Script editor... (for the spreadsheet).
You should start with a blank project.
Delete anything in there and paste in your script.
Save and name you project.
Now set up your triggers as normal. You will find the third drop down list of the new trigger has the option On form submit.
Once your script is authorised any time the form is submitted the event will trigger and will have access to the DriveApp.
Once you've tested and got it working I would go back to the form and delete the script project in there. I do that to keep things tidy and save confusion if I come to alter the script later and have forgotten which one is actually live.
I don't know if there is a limitation with Google Forms that limits their access to Drive or something.

Deleted script, no triggers, still getting emails

I deleted a google apps script from docs (Gmail Snooze), but I keep getting a message every day:
Start Function Error Message Trigger
6/9/12 12:49 AM myFunction We're sorry, a server error time-based
occurred. Please wait a
bit and try again.
I've already tried creating a new script, going to Resources > All Your Triggers, and nothing is there.
Is there a better way to get rid of these error messages than creating a new filter in gmail to auto delete them?
Have you also tried deleting the spreadsheet from the Trash in Google Docs?
There have been some reported problems around deleting triggers. You may want to add a comment on this open issue.
This worked for me!
Open a spreadsheet then go to tools-spreadsheet editor, then on the
editor window go to Resources->All your triggers... and see if the
trigger is still listed there. If so, delete it.
Source: How to delete a google apps script service
There might be an update to the interface. Triggers are now accessible trough different menu.
Open script.google.com and open any project or create a new one if you don't have any projects. Then go to Edit>All your triggers and switch off the ones you don't need.