【发布时间】:2022-09-29 04:56:55
【问题描述】:
在下面的代码中,promptUPDATE、promptUPDATE2 和 promptUPDATE3 在我按 OK 后都输出“用户点击了“否”或对话框的关闭按钮。我认为我的 if 语句可能有问题,但我不确定是什么。代码应该只在我关闭框或单击否时输出该消息。
function TextBox() {
// SET UI
var ui = SpreadsheetApp.getUi();
// SET HOT & WARM WORKSHEET
const sheet = SpreadsheetApp.openById(\'1JZ-v5n5m0_lyaoLgsHDAa78AtYNP5AsUDo2NRpJbwG4\').getSheetByName(\'HOT WARM CLIENTS\');
// SORT WORKSHEET BY DATE OF NEXT ACTIVITY
sheet.sort(9)
var today = Utilities.formatDate(new Date(), \"GMT+1\", \"MM/dd/yy\")
var ui = SpreadsheetApp.getUi();
var valuesToCopy = sheet.getRange(\"D5:J5\").getDisplayValues()
var response = ui.alert(valuesToCopy,\"Did we do work for this client today?\", ui.ButtonSet.YES_NO);
if (response == ui.Button.YES) {
const variable6 = sheet.getRange(\"G5\").setValue(today);
} else {
Logger.log(\'The user clicked \"No\" or the dialog\\\'s close button.\');
}
function promptUPDATE3(){
// Prompt for the value
var UPDATE = SpreadsheetApp.getUi().prompt(valuesToCopy+\"\\n\\n What did we help this client with today?\").getResponseText();
// Get the sheet that you want store the value in and set the value in the cell B3
if (response == ui.Button.OK) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(\"HOT WARM CLIENTS\").getRange(\"PREVIOUS\").setValue( UPDATE );
} else {
Logger.log(\'The user clicked \"No\" or the dialog\\\'s close button.\');
}}
{
promptUPDATE3();
}
function promptUPDATE()
{
// Prompt for the value
var UPDATE = SpreadsheetApp.getUi().prompt(valuesToCopy+\"\\n\\n When should we follow up with this client next? (MM/DD/YY)\").getResponseText();
// Get the sheet that you want store the value in and set the value in the cell B3
if (response == ui.Button.OK) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(\"HOT WARM CLIENTS\").getRange(\"I5\").setValue( UPDATE );
} else {
Logger.log(\'The user clicked \"No\" or the dialog\\\'s close button.\');
}}
{
promptUPDATE();
}
function promptUPDATE2()
{
// Prompt for the value
var UPDATE = SpreadsheetApp.getUi().prompt(valuesToCopy+\"\\n\\n Next Follow Up Activity?\").getResponseText();
// Get the sheet that you want store the value in and set the value in the cell B3
if (response == ui.Button.OK) {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(\"HOT WARM CLIENTS\").getRange(\"J5\").setValue( UPDATE );
} else {
Logger.log(\'The user clicked \"No\" or the dialog\\\'s close button.\');
}}
{
promptUPDATE2();
};};
标签: google-apps-script google-sheets