function sendEmails() {
const sheet = getSpreadsheetApp()
const sheetData = getSpreadsheetData(sheet).getValues();
const subjectline = "Weekly Breakdown for the week of - "
var subjectDate = Browser.inputBox('Please enter the date range for e-mail subject.', Browser.Buttons.OK_CANCEL);
if(Browser.Buttons.CANCEL = true) {
Browser.msgBox('The operation has been cancelled')
return;
}
const subject = subjectline + subjectDate
In the below code, even if I'm clicking OK by inputting the details to the input box,It gives me the same message box and stops running the script.
Browser.inputBox returns a text string. To find whether the Cancel button was pressed, use this:
if (subjectDate === 'cancel') {
Use Ui.prompt() to better detect what response was entered and which button was pressed.