0
votes

I'm trying to run this script in Google Apps script:

function onOpen() {
  SpreadsheetApp
    .getUi()
    .createMenu('Create file')
    .addItem('Create file', 'createFilesInFolder')
    .addToUi()

} // onOpen()


function createFilesInFolder() {
  //This creates the folder
  var folder = DriveApp.createFolder("MojTest");
  //This creates a file in the folder
  var file = folder.createFile('My File.txt', 
                               'Lorem ipsum', 
                               MimeType.PLAIN_TEXT);
}

It always stacks on creating the folder and exceeded maximum execution time.

Here is Execution transcript when I try to debug function:

[17-10-03 12:43:14:743 PDT] Starting execution
[17-10-03 12:50:09:107 PDT] DriveApp.createFolder([MojTest]) [414.356 seconds]
[17-10-03 12:50:09:118 PDT] Execution failed: We're sorry, a server error occurred. Please wait a bit and try again. (line 15, file "Code") [414.358 seconds total runtime]

Also functions like DriveApp.getFoldersByName().next() have same problem.

Can you tell me how to fix this?

1

1 Answers

1
votes

As far as I can see, there's nothing wrong with your script - Google just seems to be having issues with some of its servers at the moment!

I found your question after searching for a similar issue, I can't run even the most basic of functions in Google Scripts at the moment!

I guess it's just a waiting game now to see when it gets fixed!