Restore deleted script blocks - google-apps-script

please help, I accidentally removed a huge portion of my codes in Google Script and accidentally saved it. Is there any way I can "Undo" and I get my previous version back?

Try this:
In the script editor, click Use legacy editor.
In the left-hand pane, click the name of the script file you want to restore.
Choose File > See version history.
Select the version you want to restore.
Click Restore.
Alternatively, use the revision history list to copy the code of the version you want to keep and paste it elsewhere.
To return to the new Monaco editor, click Use new editor.

Related

How do I discard changes in new Google Apps Script IDE?

I've been switched over to the new Google Apps Script IDE.
If I have multiple .gs and html files in one script document I used to be able to make changes on a file a close that without saving. Now the tabs are no more and you click directly on the filename and all you can do is undo until the file is reverted.
Is there a way to revert in one step?
thanks
The new code editor has no way to close an unsaved files' edit session. There is no good way to revert back to the last saved content. The only option you have is to close or refresh the browser tab. If you close or refresh the browser tab and you have other unsaved open file sessions that you want saved, then make sure to save the ones you want.

How to revert my last action comprising few tasks in Google Sheet?

Is there any way to revert (undo) my last action which comprises sorting, removing duplicates and protecting data. Currently I am doing all these three tasks together by pressing a submenu in Google Sheets.
View or revert to earlier versions
Note: You need Owner or Editor access to see the version history.
In Drive, open your file.
Click File and then Version history and then See version history.
Click a timestamp to see a previous version of the file.
Below the timestamp, you’ll see:
Names of people who edited the document
A color next to each person’s name. The edits they made appear in
that color
To revert to this version, click Restore this version.
Reference: Link

How can I remove a bound script from a Google Sheets Spreadsheet?

I have a spreadsheet where I first created a bound script file (via Tools->Script Editor). I then (at a later time) was exploring the File menu and hit Make A Copy. I now get a "Select a project to open" with the original "myAddOns" and "Copy of myAddOns" as the choices. I would like to remove the copy. I found it in the scripts My Projects page, but when I try to remove it the original spreadsheet also gets removed. (Pulled it back out of Google Drive Trash folder)
Am I stuck with this?
Thanks!
It turns out that (as the project owner) using the File->Delete Project once I open the Script Editor works. Not sure how I got messed up before.
Turns out that all of us can forget how to do this. Thanks for asking the question. In the new editor, this feature is found in Project Details, then to the far right. Click the Trash Can that warns "Delete Project Forever". Yes, please. Hope this helps someone in the future.

How can I remove a project from a Google Spreadsheet?

I made a copy of a Google Apps Script project by mistake by choosing File > Make a copy... on Script Editor and since then every time I click Tools > Script Editor... on the Spreadsheet screen the project belongs to, I see a screen showing the two projects (original one and copied one) and I need to choose one to open the script editor. To be worse, the original script became unexecutable since I made the copy, I don't know if this is the cause of that though.
So, I'd like to remove the copy project from the Spreadsheet. How can I do that? I can't find any menu to remove project.
Thanks,
Open the "copy of" version of the script, click File -> Delete Project... This will generate a confirmation box. Click the Delete button to confirm that you would like to delete the project. This should leave your original as the only associated script.

Backing up Gapps source

I have fallen into the trap of (accidentally) deleting all scripts from the script editor. Lost 3 weeks of work in this lesson. I (maybe) will not do that again, but it raises the question "What is a complete backup solution for Gapps source?"
I, of course, can make a copy of my script either in the editor, or within Google drive. I however question if my (very complex) User interface (built using GUIBilder) is protected. So far, I have been unable to locate the code GUI Builder throws.
Also note it is not possible to download an apps script in GDrive, so how do I get a personal copy of my work product?
=====
To clarify - I know how to copy and paste the source of a script BUT this does not capture the 200 gadget GUI that was built using GUI Builder.
As to the trap door in the editor -- I had several versions of this development -- I highlighted ONE in the left hand list and requested delete (from withing the Google script editor) file/delete -- magic -- ALL SCRIPTS DISAPPEARED. I will never touch the File/Delete menu again.
In some cases, you should be able to get your code back. (EDIT - except, it seems, any script file you delete from within the script editor, and any auto-generated code related to the GUI Builder, or Forms. -- Ouch!)
Your options depend on what you mean by deleting all scripts from the script editor.
If you only deleted the text of your script while in the editor, say by Ctrl-A + del, then you can recover it within the editor. File - See Revision History will bring up a dialog that lets you time-travel back to when your script was intact.
If you deleted the file from Google Drive, then it's in a trash folder, and can be recovered from there. You'll find the Trash folder in the Drive navigation tree.
If you deleted a script "file" from within the editor, you're out of luck until Google fixes Issue 1424: There is no possibility to recover script files/projects.
If you deleted any auto-generated code related to the GUI Builder, or Forms, you can't get them back. (Forms are not included in Restore from Revision History)
If you want to store your scripts some other place, that's a good idea - that will provide additional safety for items 1 to 3, but unfortunately not 4. You will need to copy the text from the editor into another file or online repository (e.g. Github). Get into the habit of including info about Libraries in your comments, because there is no way to back up those resource links.