I would like my script to do three things depending on the button the user clicked.
Display a message that allows the user to go through a piece of information and confirm everything is correct. (This part works but I am having issues with getting 2 and 3 to work)
If the user selects yes, I would like to display a message that informs the user that an email is on its way.
If the user selects no, I would like to display a message with a link that tells the user to update sheet info.
Here is my code: "sid" is my spreadsheet
var response = ui.alert(`Hi, please confirm the recipient details Recipient: ${decisionmaker}
Email: ${email} Is this information correct?`,ui.ButtonSet.YES_NO);
if (response.getSelectedButton() == ui.Button.YES) {
sid.show('Your email is on its way to the recipient);
}
else if(response.getSelectedButton() == ui.Button.NO)
{sid.show('Please update your data sheet: https://docs.google.com/spreadsheets/d/1KTMLvumkQK-X5R6utwzSVSEE0k8OcszzQ9zQPEqdxBQ/edit#gid=0');
}
CodePudding user response:
Try it this way:
function myfunk() {
const sid = SpreadsheetApp.getActive();
const ui = SpreadsheetApp.getUi();
const d = "bob";
var response = ui.alert(`Hi, please confirm the recipient details Recipient: ${d} Email: ${d} Is this information correct?`, ui.ButtonSet.YES_NO);
if (response == ui.Button.YES) {
sid.show(HtmlService.createHtmlOutput('<p> Your email is on its way to the recipient</p'));
} else if (response == ui.Button.NO) {
sid.show(HtmlService.createHtmlOutput('<p>Please update your data sheet: https://docs.google.com/spreadsheets/d/1KTMLvumkQK-X5R6utwzSVSEE0k8OcszzQ9zQPEqdxBQ/edit#gid=0,</p>'));
}
}