Yes, the problem is how you have setup the conditional check in the if statement.
In most languages you can do this: if (response = “YES”)
But in Javascript, you need to use this: if (response === “YES”)
The first case, it just assigns the value “YES” to response.. Which is obviously not what you want.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/b6beda22-c081-41e5-be0f-f44a8c566bd3n%40googlegroups.com.
Hi Robert,
Don’t worry about it some of the language syntax baffles many but we accommodate it because we have to.
In your case, I just fixed your conditional check. But I should have checked your logic as well.
You should probably use the Google Spreadsheet UI instead of the browser one.
Here is how:
function PrelimToSending()
{
var ui = SpreadsheetApp.getUi();
var response = ui.alert(
'Is this License REALLY ready to be emailed? If so, Click YES. If not, click NO to stop it from being emailed.',
'Are you sure you want to continue?',
ui.ButtonSet.YES_NO);
// Process the user's response.
if (response == ui.Button.YES) {
// User clicked "Yes".
GoodEmailPDF();
} else {
// User clicked "No" or X in the title bar.
Logger.log('The user clicked "No" or the dialog\'s close button.');
}
}
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ea9775e7-0b8e-48e7-a05a-ff9a9fc85f25n%40googlegroups.com.
If you want to keep the browser msgbox instead, change your conditional check to:
if (response === "yes") {
You need to use lowercase yes.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/f42f9d3a-bdbc-4cc1-9478-2808a0cbaa1dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/58da73d9-2e04-43a8-b065-12c6526e7938n%40googlegroups.com.