Reputation: 6477
I have two google spreadsheets. One is a template, and the other is a Master spreadsheet containing people's names, emails, and a link to a copy of the template spreadsheet.
I wanted to automate part of the process, but I'm new to GAS and JavaScript.
I need help copying the template and access the link to this new file, so I can add this link to the master spreadsheet.
Upvotes: 0
Views: 967
Reputation: 11204
I have provided a sample code below showing what it will look like. You can start from here:
function copyTemplateAddLink() {
// Sheet IDs are found in the url after "/d/", see images below
var masterID = '1CGsdAm2ewyUYyOPcTF97uxkbdAhNlxstCH09f9BHnZs';
var templateID = '1hJ0Ze04NeCUzG8tkWPfUZOuHhEQb-dvocquRUuwnqrM';
// Setting link column to 3 as sample
var linkColumn = '3';
var masterSheet = SpreadsheetApp.openById(masterID);
var templateSheet = SpreadsheetApp.openById(templateID);
// Copy template
var templateCopy = DriveApp.getFileById(templateSheet.getId()).makeCopy("Copy of Template Sheet");
// Get url/link of the said copied template and then add it next to the bottom row, on column set above
masterSheet.getActiveSheet().getRange(masterSheet.getLastRow() + 1, linkColumn, 1, 1).setValue(templateCopy.getUrl());
}
Master before running the code:
Template:
Copy of Template generated:
Master after running the code:
References:
If I misunderstood your question and this was not the result you want, I apologize.
Upvotes: 1