0

This script lock range and works fine. But if you edit locked cell, it locks locked cell again. How to control it?

`function onEdit(e){
let protection = e.range.protect();
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit())  {
protection.setDomainEdit(false);
}
}function onEdit(e){
if (e.value == null){
let prot = SpreadsheetApp.getActiveSheet().getProtections(SpreadsheetApp.ProtectionType.RANGE);
 for (let i in prot){
 if (prot[i].getRange().getA1Notation() == e.range.getA1Notation())
  prot[i].remove();
 }
 } else {
 let protection = e.range.protect();
 protection.removeEditors(protection.getEditors());
 if (protection.canDomainEdit())
 protection.setDomainEdit(false);
 }}`
Nodirbek Khajiev
  • 79
  • 1
  • 2
  • 6
  • The code you quote has two simple triggers by the same name. Only one of them will run. See [Which function runs](https://stackoverflow.com/a/66906642/13045193). – doubleunary Jan 10 '23 at 10:16

0 Answers0