J
Jake Wesson
Member since 3/14/2019

Achievements

To start earning badges, sign up to be a Product Expert in our Product Expert Program .

Activity

No recent activity
Post history
Google Docs Editors•7/17/2019
Hey Matt, the Trending issue is not the same as mine.
Create copy of a new sheet and keep original owner no matter who activates the code.
Google Docs Editors•3/14/2019
I am running this code as a custom button. When this button is used by anyone to create a copy of the current sheet i want the original and the new sheet to be owned by the original owner of the sheet (and all permissions to be intact)

function newVersion() {
  var confirm = Browser.msgBox("Create new Version?", Browser.Buttons.YES_NO); 
  if(confirm!="yes"){return};
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.setActiveSheet(ss.getSheetByName("Budget Estimate (Internal)"));
  var currName = SpreadsheetApp.getActiveSpreadsheet().getName();
  var oldVer = ss.getRange("B2").getValue();
  var oldVerNum = oldVer.substr(1,1);
  var numVer = parseInt(oldVerNum);
  var numNew = (numVer + 1);
  var newVer = ("V"+numNew);
  var newDate = Utilities.formatDate((ss.getRange("E4").getValue()), "GMT+10", "yyyyMMdd");
  var newName = "Budget Estimate "+ss.getRange("E3").getValue()+" "+newVer+" "+newDate;
  ss.rename("tempSheetName");

  var directParents = DriveApp.getFileById(ss.getId()).getParents();
    while (directParents.hasNext()){
      var folderID = directParents.next().getId();
    }
    
  var destFolder = DriveApp.getFolderById(folderID);  
  var master = DriveApp.getFileById(ss.getId());
  var newFile = master.makeCopy(currName, destFolder);
  
  ss.rename(newName);
  ss.setActiveSheet(ss.getSheetByName("Budget Estimate (Internal)"));
  SpreadsheetApp.getActiveSheet().getRange("B2").setValue(newVer);
}
false
9116554965140633198
true
Search Help Center
true
true
true
true
true
35
false
Search
Clear search
Close search
Main menu
false