Reading differents boolean types of e.values of checkboxes on a sheet, I resumed the (odd) e.values read on a table.)
I got this values by clicking on checkboxes and triggering onEdit function. the values read are not boolean. in the table, you can see that the values read are TRUE/FALSE and string type. Reading the cell by his coordinates , it return the correct values as you can see in this other table.
you can test with this code
function onEdit(e) {
var eA1 = e.range.getA1Notation();
var ui = SpreadsheetApp.getUi();
// e.value and his typeof
ui.alert("(" + eA1 + ") e.value=" + e.value);
ui.alert("(" + eA1 + ") typeof e.value=" + typeof e.value);
// eValue and his typeof
var eValue=e.value;
ui.alert("reading of eValue......");
ui.alert("(" + eA1 + ") eValue=" + eValue);
ui.alert("(" + eA1 + ") typeof eValue=" + typeof eValue);
// getting de value of (e)cell
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var eTargetCell = sheet.getRange(eA1);
var eCellValue = eTargetCell.getValue();
// eCellValue and his typeof
ui.alert("direct reading of cell.......");
ui.alert("(" + eA1 + ") eValue=" + eCellValue);
ui.alert("(" + eA1 + ") typeof eValue=" + typeof eCellValue);
}
You can easily make a function to get the boolean value of 'e' cell. To get the correct value of e.oldValue... you can recover it in the original cell, if needed, easily by
e.range.setValue(eOldValue);
...
or in another cell(not tested this point)
I have not found help of this issue on internet, and I expend many hours drilling, I hope this can save time to others, or maybe someone can modify this code to do a better version.
Aucun commentaire:
Enregistrer un commentaire