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

104
Vistas
Searching in google sheet using app script not working with numbers

I'm trying to use app script to give access to my Google sheet by searching through a webpage. so I don't have to give all the data. the search is based on a specific column and the result can be repeatable on the column itself but the other columns of the same row like price and item are different.

with my current code if the searched column has only characters the code works perfectly but once I add numbers to the targeted column on my google sheet the code stop working .. can you help me with that .. my knowledge is basic with coding

function doGet(e) {
  
  return HtmlService.createTemplateFromFile("Index").evaluate()
  .setTitle("WebApp: Search By Password")
  .addMetaTag('viewport', 'width=device-width, initial-scale=1')
  .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}


/* PROCESS FORM */
function processForm(formObject){ 
  var concat = formObject.searchtext;
  var result = "";
  if(concat){//Execute if form passes search text
      result = search(concat);
  }
  return result;
}


function search(searchtext = 'searchtext') {
  let ar = [];
 var spreadsheetId   = '1aN8VLL4iKhGjmM84qhncG9cQfKigCWscMT-UkdzNhQs'; 
  const names = ['Data', 'Data2'];
  names.forEach((name) => {
    var range = SpreadsheetApp.getActive().getSheetByName(name).getDataRange();
    var data = range.getValues();
    data.forEach(function (f) {
    if (f[0] === searchtext) {
      ar.push([f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9]]);
      }
      
    });
  });
  return ar;
};

thanks a lot

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this f[0] == searchtext because === says the same object type and the same value. It may be preventing searchtext to being coerced into a number.

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