I am selecting values from two dropdown lists in Google Sheets. In cell A4 I select subject code like IT101, Math301, PHY105 and son on. And in cell B4 there are 'No Class, Start 1-Period and Start 2-Period' in the dropdown list.
What I want is, in A4 I will select my subject code and then when I will select any item from the dropdown list in B4 (B4 cell value is linked with onEdit Trigger), I want to see a confirmation message like "Confirm your subject..." If I press OK, it will execute the functions below like refreshSheet() and onePeriod(). But if I cancel it, it will do nothing. In this code, the issues is, it is showing message but the code is executed automatically no matter whether I am pressing Ok or Cancel button. Please advise.
function onEdit(e){
if (e.range.getA1Notation() === 'B4' && e.range.getValue() === "Start 1-Period") {
var ui = SpreadsheetApp.getUi();
ui.alert("Confirm Your Subject Details!!", ui.ButtonSet.OK_CANCEL);
if (button == ui.Button.OK){
refreshSheet();
onePeriod();
}
}
if (e.range.getA1Notation() === 'B4' && e.range.getValue() === "Start 2-Period") {
var ui = SpreadsheetApp.getUi();
ui.alert("Confirm Your Subject Details!!", ui.ButtonSet.OK_CANCEL);
if (button == ui.Button.OK){
refreshSheet();
onePeriod();
}
}
}