0
votes

I have copied a Google form, a spreadsheet and a scripting project from another Google drive. When I access the "Script Editor" menu from the form editing interface, it shows a few scripting projects to choose from, but not the one now in my drive. How do I change which project the form is attached to?

1
I don't know of any "built-in" way to make the stand alone file code bound to the Form, other than manually copying and pasting everything. It could also be done with the Apps Script API, but you'd need to write code to do that. Or you could try the Chrome browser extension to push the stand alone code to a repo, like GitHub, and then pull the code back into the bound file. GitHub Assistant - Alan Wells

1 Answers

1
votes

Using Apps Script:

As others said, you can do this with Apps Script API. You would have to follow these steps:

  • Call projects.getContent: provide the scriptId of the standalone script you have in My Drive, and retrieve the field "files".
  • Call projects.create to create a new, empty project bound to the Form. Crucially, you have to provide the ID of the Form file in parentId, in the request body. The response will be the created project. You have to retrieve the parameter scriptId from this response.
  • Call projects.updateContent: provide (1) the scriptId retrieved in previous step as a parameter, and (2) in the request body, provide the "files" field you retrieved in the first step. This way, all files in the standalone script get copied to the bound script.

Other ways:

All in all, it's probably not worth following these steps, and depending on your situation it could be more comfortable to just manually copying all script contents to the bound script.

Reference: