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

218
Vistas
how can I check if an entry already exists before its captured

I would like to validate an entry before it adds as a record by checking the student ID in "UserForm" against an array in "SDB" and if it finds a match to pop up with an error. At the moment I can add the same student multiple times which I would like to prevent.

function validateEntry() {
  var myGooglSheet= SpreadsheetApp.getActiveSpreadsheet();
  var shUserForm = myGooglSheet.getSheetByName("User Form");
  var datasheet = myGooglSheet.getSheetByName("SDB");
  var ui = SpreadsheetApp.getUi();
    
  //Validating Student Id
    
  if(shUserForm.getRange("S1") = SDB.getRange(A:A)) {
    ui.alert("Already Exists.");
    shUserForm.getRange("S1").activate();
    shUserForm.getRange("S1").setBackground('#FF0000');
    return false;
  }  
  return true;
}

Any help would be great!

Edit:Found a workaround for it by checking if the entry exists in google spreadsheets with a formula;

=IFERROR(if(vlookup(S1,SDB!A:A,1,false)=vlookup(S1,SDB!A:A,1,false),"Modify",""),"NEW")

and then running the script to check the formula

//Validating Student Id
  if(shUserForm.getRange("O1").getValue()=="Modify") {
    ui.alert("Entry Already Exists.");
    shUserForm.getRange("O1").activate();
    shUserForm.getRange("O1").setBackground('#FF0000');
    return false;
  }

It does the trick but still a one step method would be ideal!

about 4 years ago · Juan Pablo Isaza
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