0

I am creating a form dynamically and binding it to a spreadsheet via FormApp.create().setDestination(...). Is it possible to give / change the name that the linked sheet gets? (Form Responses 9 isn't really informativ in my case).

Since I didn't find anything in the API for naming the sheet, I'm thinking of going and finding the sheet, but I don't know its name in advance, just that it is of the format /Form Responses \d/.

How should I go about this?

Rubén
  • 34,714
  • 9
  • 70
  • 166
wildeyes
  • 6,767
  • 5
  • 19
  • 37
  • Can't you just check the names of the available sheets when created? For example get the sheet names, iterate through them, if they start with form responses add them to a list. Go thorough that list and check the numbers on the end by splitting the string. Whatever is the highest number you can assume the next one created is just an increment of one. Then you can just change the name. – John Thompson Dec 25 '18 at 00:44
  • You can use something like [this](https://stackoverflow.com/a/51484165/9337071) or Ruben's answer to find the specific sheet, and then standard Apps Script `Sheet` methods as appropriate. – tehhowch Dec 25 '18 at 05:21

1 Answers1

1

You could use getSheets() to get a collection of Sheets then use getFormUrl() on each of them, then on the sheet that return the right form URL you could use getName() to get the current sheet name or setName(name) to set the name that you want.

The above because the setDestination method of Class Form doesn't include a way to set the name of the destination sheet.

Rubén
  • 34,714
  • 9
  • 70
  • 166