Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda