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

383
Vistas
TypeError: no se puede leer la propiedad 'rango' de indefinido para OnEdit

Soy nuevo en la codificación y necesito ayuda con un script GS. Tengo una lista desplegable dependiente de múltiples niveles de 5k filas.

Me encuentro con un error cuando ejecuto el siguiente script. Dice TypeError: Cannot read property 'range' of undefined . Mi investigación dice que esto se debe a que el onEdit(e) se activa cuando se edita la celda, pero ¿por qué no puedo ejecutar el código para poder ejecutar el activador?

Si alguien puede ayudar aquí, estaría muy agradecido.

 var mainWsName = "Input: Transactions"; var options2WsName = "Options2"; var fifthLevelColumn = 5; var sixthLevelColumn = 6; var seventhLevelColumn = 7; var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(mainWsName); var wsOptions2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(options2WsName); var options = wsOptions2.getRange(2,1,wsOptions2.getLastRow()-1,4).getValues(); function onEdit(e) { var activeCell = e.range; var val = activeCell.getValue(); var r = activeCell.getRow(); var c = activeCell.getColumn(); var wsName = activeCell.getSheet().getName(); if(wsName === mainWsName && c === fifthLevelColumn && r > 7){ applyFirstLevelValidation(val,r) } else if(wsName == mainWsName && c === sixthLevelColumn && r > 7){ applySecondLevelValidation(val,r) } } // end onEdit function applyFirstLevelValidation(val,r){ if(val === ""){ ws.getRange(r, sixthLevelColumn).clearContent; ws.getRange(r, sixthLevelColumn).clearDataValidations; ws.getRange(r, seventhLevelColumn).clearContent; ws.getRange(r, seventhLevelColumn).clearDataValidations } else { ws.getRange(r, sixthLevelColumn).clearContent ws.getRange(r, sixthLevelColumn).clearDataValidations; ws.getRange(r, seventhLevelColumn).clearContent; ws.getRange(r, seventhLevelColumn).clearDataValidations var filteredOptions = options.filter(function(o){ return o[0] === val }); var listToApply = filteredOptions.map(function(o){ return o[1]}) var cell = ws.getRange(r, sixthLevelColumn); applyValidationToCell(listToApply,cell) } } function applySecondLevelValidation(val,r){ if(val === ""){ ws.getRange(r, seventhLevelColumn).clearContent; ws.getRange(r, seventhLevelColumn).clearDataValidations; } else { ws.getRange(r, seventhLevelColumn).clearContent var firstLevelColValue = ws.getRange(r, fifthLevelColumn).getValue() var filteredOptions = options.filter(function(o){ return o[0] === firstLevelColValue && o[1] === val }); var listToApply = filteredOptions.map(function(o){ return o[2]}) var cell = ws.getRange(r, seventhLevelColumn); applyValidationToCell(listToApply,cell) } } function applyValidationToCell(list, cell){ var rule = SpreadsheetApp .newDataValidation() .requireValueInList(list) .setAllowInvalid(false) .build(); cell.setDataValidation(rule); }
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