Reputation: 11
I am struggling with creating a script that will copy a file located on a Team Drive to My Drive for many users. I do not know how to implement a part to find My Drive of the user, it cannot be a static url address.
function saveAsSpreadsheet(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var name = sheet.getName()
var drive = ???
var name = Browser.inputBox('Save File', 'Enter the name of the file',
Browser.Buttons.OK_CANCEL);
if (name != "cancel"){
DriveApp.getFileById(sheet.getId()).makeCopy(name,drive);
}
}
Thank you for suggestions!
Upvotes: 0
Views: 842
Reputation: 1413
Try this,
function saveAsSpreadsheet(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var name = sheet.getName()
var name = Browser.inputBox('Save File', 'Enter the name of the file',
Browser.Buttons.OK_CANCEL);
if (name != "cancel"){
var file = DriveApp.getFileById(sheet.getId());
DriveApp.getRootFolder().createFile(file);
}
}
**P.S.**I am not changing the file handling logic here, I am only providing your answer to locate User's Local Drive assuming your sheet object will have file which needs to be saved.
Upvotes: 1