Thanks for your help in advance. New to scripting. Trying to set values to true in two sheets that correspond to a value in a row from a source sheet.
Example: Sheet 1 gets a row added, corresponding Sheets 2 and 3 get a column set to true.
I do not have a script example to display
When user adds a row to Sheet0 the next row in Sheets 2 and Sheet3 and column one get set to "TRUE"
function onMyChange(e) {
//Logger.log(JSON.stringify(e));
const sh = e.source.getActiveSheet();
if (sh.getName() == 'Sheet0' && e.changeType == "INSERT_ROW") {
let sh2 = e.source.getSheetByName('Sheet2');
if (sh2.getLastRow()) {
sh2.getRange(sh2.getLastRow() + 1, 1).setValue("TRUE");
} else {
sh2.getRange(1,1).setValue("TRUE");
}
let sh3 = e.source.getSheetByName('Sheet3')
if (sh3.getLastRow()) {
sh3.getRange(sh3.getLastRow() + 1, 1).setValue("TRUE");
} else {
sh3.getRange(1,1).setValue("TRUE")
}
}
}
You can goto to Google Apps Script Reference and using the search box find any function that you don't understand. If it's a pure JavaScript function then go here