Joshua Hess
Joshua Hess

Reputation: 23

Google Scripts - Copy existing spreadsheet and rename it

I am using Google Scripts. I am attempting to, upon form submission, copy and existing spreadsheet (not the spreadsheet the form submits to) and rename it based upon a cell in the submission.

I assumed that the way to do this is to identify the spreadsheet to be copied by its ID. Here is a bit of the code. Both variables (newUserSS and UUID) define properly.

  var newUserSS = "1-bOW_eIKc-dt8pX9YlwpjZTtwjEDYOPxcasSxQ9ndvM";
  var UUID = sheet.getSheetValues(newLine,2,1,1);
  newUserSS.copy(UUID);

Upvotes: 1

Views: 425

Answers (1)

Tanaike
Tanaike

Reputation: 201613

You can copy the spreadsheet using the retrieved Spreadsheet using the spreadsheet ID.

The detail information of copy() is here.

Modified script :

var id = "1-bOW_eIKc-dt8pX9YlwpjZTtwjEDYOPxcasSxQ9ndvM";
var newUserSS = SpreadsheetApp.openById(id);
var UUID = sheet.getSheetValues(newLine,2,1,1);
newUserSS.copy(UUID);

If I misunderstand your question, I'm sorry.

Upvotes: 1

Related Questions