I have a font and alignment script which works like a charm on our daily spreadsheet. However I copy the blank file (template) 30 ish times for each month. As soon as I have done this, the font script stops working unless I go in and authorise it for each new sheet. Is there any way, maybe with the script library i can run it automatically and not have to authorise each new sheet? All users have edit access to the sheet. I have been reading and playing with the script library but can't seem to get it to work at all.
Thank you for any help.
The simplest way to authorize a script and then not need to reauthorize a derivative of it, is to not create a derivative of it. Currently, you indicate the workflow is create a copy of yesterday's document, and then everyone works on the copy.
If you reverse the order, such that you archive the copy, then you will no longer need to continually reauthorize your script in a new file, as the working file contains an authorized Apps Script project.
Create a template file, which has the corresponding sheets you would like to start each day with
Write a script which will perform 2 tasks
Export the current state of the active workbook to a new workbook (or even a PDF or other archive-ready asset)
Replace the contents of the active workbook with those from the template workbook.
Run this script either manually or from a time-based trigger.
Related
My plan is to link a google app script to my google sheets. I have 16 tabs on my google sheets. I want to make 16 app script files inside the same app script project. I also want to set time trigger on each app script to run at a certain time. My question is will every file inside the app script file will run, or only one app script will run?
The output I am looking for is that I do not have to press any button on the sheets or the app script. I want it to run each app script file at a certain time, and for the google sheets to update at that time. Each google sheet tab should update at the time they are assigned in the app script. How can I make this happen?
Thanks in advance.
Every scripts are runnable, unless the function names do not duplicate.
A project is similar to a html file, while each script file is included by <script src="name.js">
However, I doubt whether you really need one script file, or even a function for each sheet.
Of course, it depends on what you want to do. But I guess the works are similar and they could be combined into one or a few functions.
I have programmed a script in a Google Sheet to treat the data stored in this script. This script runs automatically based on time.
I use a Google Sheet per month, so I make a copy of this Sheet with its programmed script every month. I modify the date and rename the file.
Nervertheless when I make the copy, it's necessary to get permissions in Google Apps Script to run the script. I would like to program a script that makes the copy, rename the file, changes the date and gets permission automatically. Making copy, renaming and changing date are easy, but I don't know how get permission automatically. Is it possible? Anyone can help me?
I added this bound script to a google sheet trying to save time by not having to manually enter the sheetname in a cell:
function sheetname() {
return SpreadsheetApp.getActive().getName();
}
Then I realised it wasn't stable so I stopped calling it from inside the sheet =sheetname(). Then I forgot about it at went on duplicating my sheet (with this bound script) to over 1000 new files.
Now I need to create a stand alone script for a different purpose, but when saving it to be able to run the script I get this message:
"The service has been used many times in a day: dev console project
create Attempts."
I managed to save the script project once but then when I tried to run it I got this slightly different error message:
Error saving project: too many scripts created in one day for this
Google user account.
So I figured: fine, I'll have to wait a day and not duplicate the file with the bound script during that time. But that didn't work. So now I seem to be stuck with here without the possibility to every add a script again from my account.
From what I understand, the bound scripts can only be accessed and disabled/deleted through each of the duplicated Google sheets script editor.
Will I ever be able to add scripts again without having to open my 1000 duplicates and delete each one of the bound script? Or by deleting the 1000 duplicates and start over? If so how?
I've already put in too many hours manually connecting each duplicated file to a master sheet manually with importrange.
From what I understand, the bound scripts can only be accessed and disabled/deleted through each of the duplicated Google sheets script editor.
Recently Google launched the Google Apps Script Dashboard. From there we could "Delete forever" bounded scripts without having to open the container.
I need to copy an existing script, which I did not write, into my existing spreadsheet. The script is called "SaveBack", and can be found here: https://docs.google.com/a/levelgroup.com/spreadsheet/ccc?key=0Agcb8bUVVOOodHhoV3BrRGZ6UEdSYnVLSEk3bllxRnc#gid=1.
My existing spreadsheet is too complex (it has many other spreadsheets that link to it) to copy all of its sheets into the spreadsheet that contains the script. I have already copied the SaveBack editor sheet template sheet to my main spreadsheet, but I can't figure out how to copy the SaveBack script that goes along with it into my spreadsheet.
Can anyone help? Thanks!
Open the save back script, select the script text, copy it, go to your sheet, create a new script (blank template), paste the script you copied into your new script, name is SaveBack (assuming it's a project), check the triggers on the original script and make sure your triggers match, and you should be good to go. You will have to change any sheet, document, or other string ID's to match your files' Id's, but that isn't too bad.
I do this sort of thing all of the time when I'm migrating things back and forth between my work and personal account. You could also create a copy of the other person's spreadsheet that you linked above, and it will move the script over with it. Then you can go to the script and get the project key to use it as library in your own scripts. Since you're using your copy as the library, you don't have to worry about someone else changing the script and breaking your functionality.
I have been trying all day and I found this:
http://www.jellybend.com/2012/12/19/monitor-google-drive-folders-with-google-apps-script/
The attached script worked only partially for me. It doesn't respond to change to the subfolders even there are files inside the subfolders (eg. rename/delete the subfolder). It also seems to have errors if I delete and re-add the same file to the folder again, it just doesn't email me for the newly added "old file".
I also found this:
https://developers.google.com/drive/v2/reference/changes/list#examples
but unfortunately I am not really sure what those parameters are and I am just inexperienced in writing something like that.
Any help will be greatly appreciated! Thanks!
The file monitoring code at that link, is an Apps Script bound to a Sheet. An Apps Script can be bound to a Sheet, Doc, Form or Site. An Apps Script can also be a stand alone application. So, any code you may want to write, does not need to be in a spreadsheet.
An Apps Script can be set up to have a Time-driven event trigger.
There is also a Script Service to build Clock Triggers.
ClockTriggerBuilder Class
Using Time Driven Event Trigger, or a Clock Trigger you could use the getSize() method to return the amount of disk space used by the item:
Class - Folder - getSize Method
// This example logs the first file's size in bytes
// Note: This can also be used on a folder to get the size of its contents
var file = DocsList.getAllFiles[0];
Logger.log(file.getSize());
Of course, you would need to know what the original size of the folder or file was, and so you would need to store the current size somewhere. You could create a file for storing that information, or use the built in database that Apps Script has.
For storing your historical folder or file information you could use ScriptDB.
ScriptDB
Quote:
ScriptDB is a JavaScript object database for Google Apps Script. Each script project gets a database, which the script can use to save, update, and search JavaScript object data.
You could write historical file and folder info to a spreadsheet or document also.
Depending on who owns the file, and who is accessing the file, permissions would need to be granted, or you'd need to use oAuth2 to authenticate who has access to the file and folder information.
If you can't write all the code yourself, you could set up a shared Apps Script file, or find some other way to have people collaborate on the project.
I've been researching this on my own for some time and came up with a script bound to a spreadsheet as well. Hope it can help someone, as it seems that a lot of people are looking for something similar. My script is monitoring a folder and sends notification to all the current viewers of the folder as soon as there is new file added. Trigger to run the script could be set depending on the needs of the user. In my case hourly worked just fine.
Spread Sheet with the script: https://docs.google.com/spreadsheets/d/1CzVADjUTT2d9Y5OGDOnv37mCaO49kPt4RmnyZgzjTKA/edit#gid=0
If you would like to try this script just make sure you are logged in with your google account when you open the link and you should be able to make a copy of the spreadsheet.
This Google Script will send an email notification to you or other email addresses when a file in a Google Drive folder has been added, renamed, changed, or modified. http://baumbach.com/google-script-2/