0

我希望收到每日報告中未在我的電子表格中標記爲「已完成」的項目。我有將通過電子郵件發送報告的代碼,但我需要添加一行或兩行代碼,以過濾出狀態不等於「已完成」的任何內容。此外,隨着此項目的增長,我想添加功能以根據多個項目進行過濾(例如,僅顯示Col D中標記爲完成的項目,並將其分配給Col B中的Greg)。過濾標準電子郵件報告

片是在這裏:https://docs.google.com/spreadsheets/d/1jA4XQa7MgQI7OOLwCcmGv7BcUKSjdIPyh6B0CeQI-PI/edit#gid=0

因爲目前的情況是我的代碼...

function emailStatusReport() { 

    // Set variables. 
    var x = 13; 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var sheetName = ss.getSheetByName('data'); 
    var template = HtmlService.createTemplateFromFile("report.html"); 
    var message; 
    var subject; 
    var emailQuotaRemaining = MailApp.getRemainingDailyQuota();  
    var theRange = ss.getDataRange(); 
    var completeMessage = ""; 
    //Logger.log(theRang.getA1Notation()); 
    var theManualRange = ss.getRange("A1:C7"); 
    // var dateTimeStamp = now(); 
    var vals = theManualRange.getValues(); 
     for(i=0; i<vals.length; i++){ 
     var itemNumber = vals[i][0]; 
     var title = vals[i][1]; 
     var description = vals[i][2]; 
     // Logger.log(itemNumber + " " + title + " " + description + " "); 
     completeMessage = completeMessage + ("<BR>" + itemNumber + " " + title + " " + description + "</BR>"); 
      } 

      Logger.log(completeMessage); 

// Logger.log (x); 
// Logger.log (ss); 
// Logger.log (sheetName); 
// Logger.log ("Remaining email quota: " + emailQuotaRemaining); 
// Logger.log (vals[i][0]); 



subject = "Daily Status Report TEST..." 
message = "<HTML><BODY>" +   
     "<Font Face='verdana' color='green' size='2'>" + 
     "<P><P><B>Daily Status Report TEST</B>" + 
     "<P>Please review the report listed below. " + 
      // "<P>The value of x is " + x + "." + 

     "<P>" + completeMessage + 
     "<P><P>" + 
     "For the most up-to-date information, please visit: <BR>" + 
     "https://docs.google.com/spreadsheets/d/1jA4XQa7MgQI7OOLwCcmGv7BcUKSjdIPyh6B0CeQI-PI/edit#gid=0" + 
     "<P>" + 

     "<P><B>Make it an amazing day!</B>" + 

      // "<P>Report generated at: " + dateTimeStamp + ". " + 
     "<P>Remaining daily email quota: " + emailQuotaRemaining + ". " +   
      // "<P>This report runs between ___ AM and ___ AM." + 

      "</HTML></BODY>"; 


MailApp.sendEmail("[email protected]", subject, "", {htmlBody: message}); 


// Logger.log("Subject is :" + subject); 
// Logger.log("Message is: " + message); 




} 

回答

0

對於你的問題:要接收未標記項目的每日報告「已完成」

首先改變手動量程,包括狀態欄:

var theManualRange = ss.getRange("A1:D7"); 

然後將您的for循環更改爲:

for(i=0; i<vals.length; i++){ 
     var itemNumber = vals[i][0]; 
     var title = vals[i][1]; 
     var description = vals[i][2]; 
     var status = vals[i][3]; 

     // Logger.log(itemNumber + " " + title + " " + description + " "); 
     if (status != 'Completed') { 
     completeMessage = completeMessage + ("<BR>" + itemNumber + " " + title + " " + description + "</BR>"); 
     } 
      } 
相關問題