Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Rename spreadsheets created in AppScripts Forms

I am using a script that generates programatically some forms. I am registering the answers in a separate google spreadsheet. The problem is, whenever a new form is created, a new spreadsheet is created in my spreadsheet too. So, one spreadsheet for each form created. Is there any way to rename the new sheets created so that I'll be able to know which sheet corresponds to the created form.

Or even better, log all the responses in just one master sheet.

My appscript file is a standalone file:

I log the submitted responses with:

destination=SpreadsheetApp.openById('id');
form.setDestination(FormApp.DestinationType.SPREADSHEET, destination.getId())
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is, whenever a new form is created, a new spreadsheet is created in my spreadsheet too. So, one spreadsheet for each form created.

I don't see that happening in the code provided. I can only see additional response sheets due to forms being linked in the same spreadsheet.

If what you mean is rename the created sheet on the same spreadsheet where the form is linked in your code, then see below approach.

Code:

function myFunction() {
  revisedSheetName = 'revised name';
  id = 'id'
  form = FormApp.create('test form');
  destination = SpreadsheetApp.openById(id);

  // get old set of sheets before form linking
  oldSheets = destination.getSheets().map(sheet => sheet.getSheetName());
  form.setDestination(FormApp.DestinationType.SPREADSHEET, id)
  // apply pending sheet creation
  SpreadsheetApp.flush()
  // get new set of new sheets (including new creation)
  newSheets = destination.getSheets().map(sheet => sheet.getSheetName());

  // get name of new sheet by getting the difference of new and old sets of sheets
  newSheetName = newSheets.filter(sheet => !oldSheets.includes(sheet));
  // access new sheet, then rename
  destination.getSheetByName(newSheetName).setName(revisedSheetName);
}

Sample:

sample

Output:

output

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!