Does anyone know if it would be possible to set up a script on my Google account that triggers when a new item is shared to the email and then automatically shares it with another email address?
I use a personal Gmail account, but whenever I do school work documents are always shared with my school email and it is a pain to have to share everything manually or keep switching accounts.
When I looked a few weeks back I was unable to find a way to have a script trigger on new shared items, but I am new to these scripts so if anyone has a suggestion I would appreciate it. Thanks!
I don't think you can actually triggers on new items. But you can write a script to read the Drive feed to easily check if there's new files.
Such script would still have to be triggered on a time-driven basis, so you wouldn't have "instant" access on your second account. Also, if I'd write such script, I would just create a folder, share it with the desired accounts, then use the script just to move the files to this folder. This approach has the benefit of easily allowing you to check which files are shared (with your specific account) and which aren't. And since folders are actually just labels in Drive, it is not any problem if you like or need to have your files organized in another folder structure.
By the way, have you seen Chrome users feature? It helps a lot when working with multiple accounts.
Related
I have google sheets addon in Google Workspace Marketplace. I want to store the emails of the users installing the addon. I'm thinking of three possible ways.
Write to private spreadsheet under the addon account (different than the user's). Addon is running under user's so the question is, is this even possible - accessing the addon account (specifically writing to a spreadsheet) from within the user google account context?
using PropertiesService - Write the user to script properties using PropertiesService class.
One problem with this one is the limitations as explained in Quotas for Google Services.
for me, at lease for now, this is enough.
However the question is how to access those script properties programmatically.
Of course I can access the data from the script editor, but this is not practical if I want for example to send mail to all the users.
adding code to the addon that will be available only for specific users (admin). In this case since I can read the users from the script properties, and maybe write them to spreadsheet to be used later. This looks ugly, I admit.
I'm not asking for code solutions, but suggestions for the right or best approach.
The easiest solution is to create a database
Create a spreadsheet located on your Drive, shared as "Everyne can edit".
Implement a flow where after Add-n installation data containing the user"s email will be appended to the spreadsheet.
This request will take place on user's beahlf, however given that the spreadsheet is shared publicly, there won't be any access permission issues
Even if the spreadsheet is shred publicly - given that the spreadsheet id is not known by anyone other than the Add-on code, you do not need to worry about undesired access to the database.
I'm setting up a google spreadsheet to give my client to use.
However, we both are using organization ID's meaning that we cannot directly share our sheets to one another.
So, I have to download and send the google spreadsheet but the formulas and app scripts break if I download it as an xlsx file.
Is there a way to share the file??.. I don't want to have to borrow my client's laptop and do the process over again.
(BTW, of course there's no such option as "Set the sheet public" or "Allow anyone with link to access")
I'd really appreciate your help. Thanks in advance.
It sounds like you may want to share files that have restrictions in place to prevent them from being shared.
Thankfully there seems to be no way to do that.
As a workaround you could potentially manually copy the data and script into a new sheet, you would now be the owner, leaving you the possibility of sharing it. Though of course, you should check with your admin to ensure that this is not violating any company policy.
I own 2 spreadsheets. One Master and one template.
On Master, I add patients and create a new spreadsheet for this client as a copy of the template. At this moment I give the client Edit access to this file.
This worked fine. But now I have to add staff and each of them needs Edit access to each copy of the template and Read access on the master.
Staff members come and go. I wonder what is the best way to simplify authorization.
Now I loop thru all files and give/revoke for each document. This is not performing in the long run.
Can I apply permission to a folder? or to a group and just add/remove staff to this security group? I'm new to the google apps script, hope you can show me the right path.
EDIT: Now I'm here
I need staff member to have access to view the master and edit any of the copies of the template. Also, I need people from outside the organization to have access to edit their own copy of the template.
I'm not sure how to proceed.
Also, I develop all this under my own Gmail account, now I have to move this into the orbit of the organization. What are the steps?
In your case, the easiest might be to create a Google Group and share your spreadsheet with it
When the staff members "come and go" you can simply add and remove them from the Google group and do not need to touch the spreadsheet's sharing settings.
Btw, when you create a copy of your spreadsheet programamtically, you can retrieve the editors of the current spreadsheet with getEditors() and assign them to the copied spreadsheet with addEditors()
I have written a Google Spreadsheet script which reads data from a user provided CSV file, populates a sheet with the data, makes a copy of the spreadsheet with a different name, and provides a link for the user to click to see the new spreadsheet. After making the new copy, the original spreadsheet is then cleared of user data and restored to its original state so other users can use it.
I want to share this spreadsheet with the workgroup (several hundred users), but I don't want them to be able to modify either the sheet or the script. If I share it read-only the script won't run, but to get the script to run I have to allow users edit capability and that is a bad thing.
I have googled myself silly trying to find a direction in which to go, but I am still wandering in the wilderness.
Can any of you point me in the right direction? If I need to be more specific or provide more information I will be glad to do so.
Thanks,
Larry
P.S. Other questions of note:
o Is it possible for a app-script in a spreadsheet to make the new copy active and 'close' the original shared spreadsheet?
o Can the user be made the owner of the new copy?
There is the option to put the code that you don't want modified, into a Stand Alone Apps Script file, then use that code as a "Library" in your script bound to the sheet. You can set the permissions on the Stand Alone Apps Script to VIEW only. That will keep people from changing it. When you share the Apps Script file with the users, they will get an email notification. So, they'll have the URL to the file, and can view it, but they can't edit it. (If you set it to VIEW only)
So, you'll be using both your spreadsheet file, and a Apps Script file. Two files, and setting the sharing to VIEW only on the Apps Script file. You can still give people EDIT access to the spreadsheet.
You'll need to go through a process of making the function available to your spreadsheet. This is called a "Library", but don't pay much attention to that name when creating the file.
Create a Stand Alone Apps Script
Create the function you want to share.
Get the Project Key --> FILE, PROJECT PROPERTIES
Share the Apps Script file with users you want to give access to, but only give them VIEW access to the file. NOT Edit.
Give the Project Key to the user, (In this case that's just you.) and have them add the library, or if you have access to the spreadsheet, you can probably add the key yourself. So, in your case, you will not be sharing the Project Key with anyone. You don't need to.
In the script file that is bound to the spreadsheet, click the RESOURCES menu, and the LIBRARIES menu item.
Enter the Project Key
Click SELECT button, and turn the library ON.
Make sure to set the library Identifier to a key word you'd like to use.
Go to the code editor, create a function, and type the Library Identifier.
All the functions that are available from the Library will show up
Google Documentation - Gaining Access to a Library
Keep in mind, that creating a library is nothing more than writing code in an Apps Script in a stand alone Apps Script file. If you've done that, then all you need to share is the Project Key. The user of the Library won't see a list of all the available Libraries when Resources, Libraries is opened. You need the Key.
I am Ashwin. I have a scenario on Google App Scripts. " Whenever a user clicks on the 'Create' button in Google Drive, that particular file should automatically be shared with a particular email address". Can anyone help me out in this?
While this is possible with Google Script, an easier option would be that you create a separate folder in your Google Drive and share it with an email address. Now any file that you create inside that folder will automatically be available to that address.
The suggestion on using a folder is good. Else with script you cant hook into drives create button. But you can have a script on that user on a time trigger constantly searching for files created/modified since last time you checked and if the user is owner, share it with the other email. Even better share it with a google group so later is easier to modify the shared-to user on a single spot.