fork download
  1. function copyWithProtections(){
  2. const sh = SpreadsheetApp.getActiveSpreadsheet();
  3. const ss = sh.getSheetByName("Template");
  4. const prot = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE)
  5.  
  6. let nSheet = ss.copyTo(sh).setName(sh.getNumSheets()-1);
  7. let p;
  8.  
  9. for (let i in prot){
  10. p = nSheet.getRange(prot[i].getRange().getA1Notation()).protect();
  11. p.removeEditors(p.getEditors());
  12. if (p.canDomainEdit()) {
  13. p.setDomainEdit(false);
  14. }
  15. }
  16. }
  17.  
Success #stdin #stdout 0.35s 42288KB
stdin
Standard input is empty
stdout
Standard output is empty