Bonjour,
Les protections sont bien mises :
MAIS le niveau de protection est trop faible, il autorise tout le monde.
+ il faut que le script retire la protection sur la ligne n'est pas complète.
Voici un script modifié, ça semble fonctionner, à tester:
function onEdit(e) {
const sheet = e.source.getActiveSheet();
var editRow = e.range.getRow();
const startRow = 9;
var now = new Date();
var horodat = Utilities.formatDate(now, Session.getScriptTimeZone(), "dd/MM/yyyy - HH:mm:ss");
if (editRow > startRow) {
const nbVal = sheet.getRange(editRow, 1, 1, 3).getValues().flat().filter(value => value !== "").length;
var rangeToProtect = sheet.getRange(editRow, 1, 1, 3);
var protections = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE);
if (nbVal === 3) {
var protectedRanges = protections.some(function(protection) {
return protection.getRange().getA1Notation() === rangeToProtect.getA1Notation();
});
if (!protectedRanges) {
var protection = rangeToProtect.protect().setDescription("Ligne " + editRow + " complétée le " + horodat);
protection.removeEditors(protection.getEditors());
protection.setDomainEdit(false);
}
} else {
protections.forEach(function(protection) {
if (protection.getRange().getA1Notation() === rangeToProtect.getA1Notation()) {
protection.remove();
}
});
}
}
}