我已粘贴下面的示例
代码:
function ck() {
//assigning variables
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var lastrow = ss.getLastRow();
var valsr7 = sheet.getRange(lastrow, 3).getValue();
var valsr30 = sheet.getRange(lastrow, 4).getValue();
var valsrn = sheet.getRange(lastrow, 5).getValue();
var valINC7 = sheet.getRange(lastrow, 6).getValue();
var valINC30 = sheet.getRange(lastrow, 7).getValue();
var valINCn = sheet.getRange(lastrow, 8).getValue();
var service = sheet.getRange(lastrow, 2).getValue();
var now = new Date();
var wk = now.getWeek();
//now assigning values to variable
var A = valsr7;
var B = valsr30;
var C = valsrn;
var D = valINC7;
var E = valINC30;
var F = valINCn;
var AB = AB;
if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 ){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext@lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94@gmail.com"})
}
if(service == 'Global-Servicenow-Support-T2' && A == 0){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext@lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not Updated more than 30 Days = "+B+""+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94@gmail.com"
});
}
else {
}
if(service == 'Global-Servicenow-Support-T2' && B == 0){
MailApp.sendEmail({
to: "prathamesh.padosakar.ext@lafargeholcim.com",
subject : "Open Tickets Global-C&k-T2 - Week-"+wk+"",
htmlBody: "Dear ABC, "+
"<p>Not updated more than 7 Days = "+A+" "+
"<p>Not assigned to any one = "+C+""+
"<P>   "+" "+
"<p>Not updated more than 7 Days = "+D+" "+
"<p>Not Updated more than 30 Days = "+E+""+
"<p>Not assigned to any one = "+F+""+
"<p>   "+" "+
"<p>Best Regards,"+
"<br>Global Service Desk "+,
cc: "techno.pratham94@gmail.com"
});
}
else {
}
当我通过if(service == 'Global-Servicenow-Support-T2' && A == 0)
和if(service == 'Global-Servicenow-Support-T2' && B == 0)
传递条件时,它给出了单输出输出或正确输出。当我通过条件if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )
时,它会给出下面提到的所有3个条件的输出。
if(service == 'Global-Servicenow-Support-T2' && A == 0)
以及if(service == 'Global-Servicenow-Support-T2' && B == 0)
和if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )
当我通过条件if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )
时,请帮助我想要单输出。
答案 0 :(得分:0)
更改条件
if(service == 'Global-Servicenow-Support-T2' && A == 0){
到
if(service == 'Global-Servicenow-Support-T2' && A == 0 && B != 0){
并改变条件
if(service == 'Global-Servicenow-Support-T2' && B == 0){
到
if(service == 'Global-Servicenow-Support-T2' && B == 0 && A != 0){
然后您将有if (service == 'Global-Servicenow-Support-T2' && A ==0 && B == 0 )