Exception: Failed to retrieve form data. Please wait and try again - google-apps-script

I intended to write a script for
Changing uploaded file name
Changing file upload folder.
As I am new to Apps Script, I decided to do up 2 separate scripts to test and merge when both are working. I have since gotten both scripts to work as intended but suddenly the auto trigger for on form submit is not working. Throwing the following error.
Exception: Failed to retrieve form data. Please wait and try again.
When I manually run the scripts, it is still working so I assume my coding is correct. I came across an article stating that adding
var form=FormApp.getActiveForm();
will help but it doesn't for my case.
Can anyone help please?

Related

Simple function suddenly throws "An unknown error has occurred, please try again later"

Since today morning, I am getting the below message while trying to run new App scripts on a new Google sheet.
Error An unknown error has occurred, please try again later.
My other App scripts attached to existing Google sheets continue to run fine. But if I create a new sheet and add even a plain simple function as shown below and try to execute this, I get the above error after it attempts to run it for some time and then gives up.
function Mytest()
{
}
I suspect that it is not able to bring the permission box which it use to bring up for any new script created. Till yesterday, once the permissions dialog box comes up and I used to give the permissions, the scripts use to run fine. But today it is not even bringing up the permission dialog box.
It looks like there is a outage going on with Google Apps Script when running new projects. I can see a couple of people reporting it in Google's public issue tracker.
It looks like it is only affecting new projects but most old projects are running fine. In the meantime you can add more info to the report to bring more attention to it. I have made some tests in 4 different accounts from different organizations and I can confirm I am also affected by this.
A couple users are reporting that it started to fix itself, and it looks like clearing cache and cookies from the browser may solve the issue (this is not a definitive solution but may work for you).
Only happens with Apps Script-managed Google Cloud Platform projects. Seems okay if you manually set the GCP project with the id using Resources > Cloud Platform Project...
I tried this because mine started with this error:
We're sorry, there was an unexpected error while creating the Cloud Platform project. Error code DEADLINE_EXCEEDED
I was having the same issue. Adding the script ID to the Library seemed to fix it.
Go to the "settings" option in the left menu of the script editor and copy the script id. Then click the plus icon next to the "Library" option and click "look up". Once the script is found, click "add" and run the script.

Google App Scripts Error "This document is too large to be edited offline. Go online to resume editing."

When I run my google app script, which used to work fine, I keep getting the error message
"This document is too large to be edited offline. Go online to resume editing."
After this message, I close the Google sheet and try to reopen but it won't let me for about 10 minutes. I have no idea why this is happening and how to fix it. Can anybody help me?
I think the problem is caused by the following code that shifts rows down and inserts a row at the top of a Google Sheet:
sheetLog.insertRows(2, 1);//shift all rows down (in history) by length of log
sheetLog.getRange(2,1,1,logResults[0].length).setValues(logResults);

Permission denied when trying to create a spreadsheet using Google script API

In the corporate environment with a corporate account I have a Google Document. Think of it as a master document that is being maintained.
I want to add a script to it to create a derived spreadsheet that can be used by people who need a subset of data from the master document.
In the master document I created a script file so the script is bound to the document.
Inside the file I defined a function. Function does some search and processing in the master file without problems but once I try to create or open an existing spreadsheet to extract data from the master document to a derived document the call fails.
I tried several approaches:
SpreadsheetApp.openByUrl();
SpreadsheetApp.create("My test sheet");
and approach covered in the solution
I also tried execution from an installed menu trigger or from debugger - same result.
In all cases I get a pop up with :
Authorization required
{doc name} needs your permission to access your data on Google.
with two buttons to review and cancel.
Clicking review leads to a message "An unexpected error occurred" at the top of the screen.
I tried different machines and browsers and switched V8 engine on and off.
I also made sure that the document is open to all in my org if I try to open an existing doc by URL.
What am I doing wrong?
It turned out that there were two things.
Adding scopes solved the problem.
I had an invalid scope that
was already there (I do not know how it got there, probably from an
example) that I preserved in the manifest and might have misspelled.
That was a mistake. It caused all sorts of instability. Only when I
tried to execute the script in FireFox instead of Chrome was I able
to see a popup that gave me a hint that one of the scopes is invalid
and I need to fix it.
Once I fixed it, everything started to load as expected.

We're sorry, a server error occurred. Please wait a bit and try again

I have several scripts bound to a spreadsheet that create 14 folders containing a total of about 240 google sheets. The original sheet that the scripts are bound to contains about 34000 rows of data that are divided among the newly created sheets. While I was working on it I frequently deleted and recreated all the folders and sheets and it worked fine. Yesterday, as I'm ready to do my final run and create the spreadsheets that will be shared and used I started getting "We're sorry, a server error occurred. Please wait a bit and try again". I tried again this morning and got the same thing.
I have tried a different browser. I created a new sheet and copied the scripts over. Then I deleted all but a single script that creates the folders and commented out all of the code in that except 3 lines that get the current spreadsheet and write out a message but I'm still getting the error.
The link to my stripped down, barely there but still not working spreadsheet is https://docs.google.com/spreadsheets/d/18_FjSpuGONEVzNZu5Ta8hm0YopsdlZlPRRAV7cx5VTE/edit#gid=1999362590
I'm thinking it may have something to do with my user account, or having reached some quotas. Is there any way to check that?
If you reach a quota when using a Google App Script, it should notify you with a specific exception. The quotas themselves can be seen here.
Have you tried removing the permissions for the script and authorising it again? I have had this issue previously and this resolved my problem (although, I accept it will not always resolve this problem...).
I would post the link, but I don't have enough reputation to post more than 2 links... Google "See apps connected to my Google account".

Error running Google App script

I created an script in https://script.google.com/
and if I open the script in the browser I get the desire result
However, If I try to included it as part of Google Site, following the steps:
Edit Site
Insert --> App Script
and pasting the URL that works above
I get the following error: It didn't get me the error before with the same script, so I'm not sure if it is because any type of limitations in the number of scripts I can run or somehting like that
Sorry, the file you have requested does not exist.
Please check the address and try again.
thank you very much
this is a very old bug in apps script. to fix, change your url "script.xxxx..." to "sites.xxxx...".