Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda