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.
Related
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?
i have a google sheet , i wrote two scripts under it. one is "Dependent Dropdown" and another is for "Reset Data" to clear entries. Everything is working fine in my machine. script working ,dropdown also working with no issue.
but i have to share sheet with my colleague to edit this. i shared sheet with permission "Anyone with the link can edit".
now my colleagues can edit perfectly BUT those two scripts are not working.
do i have to set script permission ? or what? help please.
thanks in advance
unfortunately, that's the bottleneck of scripts - each colleague of yours needs to authorize the scripts otherwise they won't work for them.
there are installable triggers - https://developers.google.com/apps-script/guides/triggers/installable but user interference is still needed.
one way would be to create a shared account where scripts are authorized and then every user would use that account to access the spreadsheet
I have a Google spreadsheet with a function: appendComment that is attached to the onEdit installable trigger for the sheet.
Permissions for the sheet are set to both link sharing (anyone with link has edit permission) and specific users with edit access.
setting up:
I have a menu item added in the onOpen trigger which starts the script permission process, giving permission for the scripts to run for that user. It is a simple MsgBox call inside a function called getAuthorization. To initiate authorization for the scripts in the sheet, the user selects the only item from the "SCG" menu, which initiates the process.
the problem:
After authorizing the script, I make the trigger fire by clicking on a checkbox in a cell on the sheet (the appendComment function only operates when I click in that column), I get a permissions error that looks like this:
You do not have permission to call prompt (line 30, file "")
This is infuriating... can't find this problem and its resolution anywhere.
Both Browser.inputBox and ui.prompt cause the same error.
Here is a simple reproduction of the problem in a google-sheet for anyone who wants to take a look:
https://docs.google.com/spreadsheets/d/1WxVTulbqT8dtUlHEf_TW_Jaus5a1GSfXnjgdoWYhrls/edit?usp=sharing
Any help is appreciated!
To achieve the result I was going for... controlled comments history with easy comment entry by users on a sheet... I did away with the prompt boxes and just used the adjacent cell instead.
Ended up putting my function in the onEdit trigger.
No box neededed, no permission issues, works even better than with the checkbox.
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.
I am writing a script for google sheets, and I need to know if the following is possible:
If a user does not have editing permission for a sheet, could they still run scripts which edit the sheet?
Basically, my goal is this: I have a sheet of data, and certain people need to be able to edit certain cells. However, I do not want them directly editing the spreadsheet, so I have created a GUI that allows users (which the script validates) to edit particular cells. Will the users be able to run the scripts which edit cells if they do not have permission to edit the sheet itself?
Thanks,
Jordan
I had came across this same requirement. I did some work around.
In your case what you can do is
1. Create a hidden sheet. This will not be protected for any user, but it will hidden
2. Save the data that is entered through GUI to this hidden sheet and then call onEdit form here.
3. onEdit will move the data in hidden sheet to the visible-protected sheet.
Since onEdit works under the script owners id it will be having access to the visible-protected sheet.
This way has worked for me. Please check.
Best
That's easy to test by yourself... try this sheet with "view only " rights
No possibility to run a script ! not even running the installed onOpen trigger.
The only way to get such a workflow it to deploy a webapp that runs "as you" where users could view and edit the cells in the Ui itself and have the webapp reflect/update the spreadsheet.
Quite a lot of work (depending on the complexity of your spreadsheet) but perfectly doable.