谷歌表脚本是否和X对话框

时间:2018-06-25 00:20:48

标签: google-sheets

大家好,有人可以告诉我如何在X按下rig时退出该脚本,现在看起来就像在按No一样。 任何帮助将不胜感激

谢谢

function ticketSaveEmailYesNo(){
// Display a dialog box with a message and "Yes" and "No" buttons. The user 
//can also close the
// dialog by clicking the close button in its title bar.
var ui = SpreadsheetApp.getUi();
var response = ui.alert(
 'Please Confirm',
 'Email a copy of this ticket to the client', 
 ui.ButtonSet.YES_NO);

 // Process the user's response.
 if (response == ui.Button.YES) {
 ticketSaveAndMail();
 } else {
   ticketSavePDF()
 }

 } 

1 个答案:

答案 0 :(得分:0)

将“处理用户的响应”更改为

 if (response == ui.Button.YES) {
  ticketSaveAndMail();
 }
 if (response == ui.Button.NO) {
  ticketSavePDF()
 }
else {

 }
 } 

这将处理“否”响应。否则将处理X。