I cannot find the way to properly simplify the nested loops to build an array of values and data validations and then set them all in the sheet in a single call to the server. Is it even possible ??
function onEdit(){
testValidation()
}
function testValidation() {
var sheet = SpreadsheetApp.getActiveSheet();
var source = SpreadsheetApp.getActive().getRange('A3:J4').getValues()
var destination = SpreadsheetApp.getActive().getRange('M3:V4');
destination.clearDataValidations();
var validationRule = SpreadsheetApp.newDataValidation().requireCheckbox().build(); // checkbox
for(var r = 0; r <= source.length - 1; r++) {
for(var c = 0; c <= source[0].length - 1; c++) {
if(source[r][c] ==="" ){
sheet.getRange(r + 3,c + 14).clearDataValidations().setValue(null)
}else{
sheet.getRange(r + 3,c + 14).setDataValidation(validationRule).setValue("true")
}
}
}
}
Link to shared spreadsheet : https://docs.google.com/spreadsheets/d/1fyFPIssp3zUjRmWxU9LqHvpowH8SHdMQYizNOZ3xKsA/edit?usp=sharing