Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Email is not sending

Code Runs No Errors But I Do Not Receive and email when I check my gmail

This line is the issue I believe I am writing this incorrectly so its not sending the email help please

if(values.getDisplayValues() === "On-going" || values.getDisplayValues() === "" && values1.getDisplayValues() >= 80)

Rest of the code:

function sendEmail(){

var ss = SpreadsheetApp.getActiveSpreadsheet();
var SpreadsheetID = ss.getSheetId(); 
var spreadsheetURL = ss.getUrl(); 
var SpreadsheetID = spreadsheetURL.split("/")[5]; 
var filterViewName = 'PO_Log Precentage'; 
var filterViewID = filterId(SpreadsheetID, filterViewName); 
var url = createURL(spreadsheetURL, filterViewID); 
Logger.log(url);// Testing to see the correct url is created 
var po_numID = ss.getSheetByName("Purchase Orders List").getRange("A2").getDisplayValue().substr(0,3);
Logger.log(po_numID);
var email_va = ss.getSheetByName("Purchase Orders List");
var values = email_va.getRange("Q2:Q");
var values1 = email_va.getRange("T2:T");
Logger.log(values)
var emailDataSheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/17G0QohHxjuAcZzwRtQ6AUW3aMTEvLnmTPs_USGcwvDA/edit#gid=1242890521").getSheetByName("TestA"); 

Logger.log(emailDataSheet.getSheetName());


 var emailData = emailDataSheet.getRange("A2:A").getDisplayValues().flat().map(po => po.substr(0,3));
    Logger.log(emailData)

    var subject = po_numID + " Po Log Daily Notification "; 
    
    
    var options = {} 
  
    options.htmlBody = "Hi All, " + "The following" + '<a href=\"' +url+ '" > Purchase Orders </a>' + "are over 80% spent" + "";

    // I believe this if statement is the problem I am writing it in correctly 
      if(values.getDisplayValues() === "On-going" || values.getDisplayValues() === "" && values1.getDisplayValues() >= "80%"){
      
     emailData.every((po, index) => {
    if (po == po_numID){
      const email = emailDataSheet.getRange(index + 2,7).getValue();
      console.log(email);
      MailApp.sendEmail(email, subject, '', options); 
      return false;
    } else {
      return true;
    }
  });
  }  
}

https://docs.google.com/spreadsheets/d/1QW5PIGzy_NSh4MT3j_7PggxXq4XcW4dCKr4wKqIAp0E/edit#gid=611584429 Here is the spread sheet

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

values.getDisplayValues() gives you an array.

Basically it makes no sense to compare an array and a string with === and >= etc.

You need to decide which element of the array there should be. May be something like values.getDisplayValues()[0][0] (because it's likely an 2D-array). I can't check your code, so just a guess.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!