Stephen Matheny
Stephen Matheny

Reputation: 1

How do I send a message to the user when their email does not match typed input email?

I have an email typed into field in my html file. I also have the user email captured by the Code.gs file.

I have figured out how to check to make sure these two match. However, I cannot figure out how to make a pop-up message (alert of any kind) appear on the user's screen when these do or do not match. (EX: 'user email does not match typed email' when failed and 'successful match' when it match)

if(userEmail == typedEmail){
  Logger.log('Success!');
}
else{
  Logger.log('Fail!');
}

I would like to add a message before Logger.log('Success!'); and Logger.log('Fail!');

The Logger.log is working correctly.

Upvotes: 0

Views: 48

Answers (1)

ross
ross

Reputation: 2774

Requirement:

Send an alert to the spreadsheet user if email addresses don't match.


Solution:

Since I don't have the rest of your function I can't format the code too well, but this section should look something like this to achieve your goal:

var ui = SpreadsheetApp.getUi();
if(userEmail == typedEmail){
  ui.alert('Successful match');
  Logger.log('Success!');
} 
else{
  ui.alert('User email does not match with typed email');
  Logger.log('Fail!');
}

Explanation:

We can use ui.alert() to send an alert to the user of the spreadsheet, all you need to do is define the message inside your brackets. I copied the ones from your question as an example.


References:

  1. Class Ui Documentation

Upvotes: 1

Related Questions