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

146
Vistas
Abra una URL usando la casilla de verificación incrustando un script

Quiero crear una secuencia de comandos de Google que abra una URL en la misma fila que la casilla de verificación cuando esté marcada o marcada. Mis casillas de verificación comienzan en A3:A y sus enlaces correspondientes están en C3:C

salida correcta

resultado del proyecto

Casilla de verificación de apertura de URL

Este script abre solo la primera celda:

 function processSelectedRows() { var rows = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("n- gadget").getDataRange().getValues(); var headers = rows.shift(); rows.forEach(function(row) { if(row[0]) { Logger.log(JSON.stringify(row)); setCellColors(); openURL(); } }); } function setCellColors() { //Get the sheet you want to work with. var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("n-gadget"); //Grab the entire Range, and grab whatever values you need from it. EX: rangevalues var range = sheet.getRange("A1:A"); var rangevalues = range.getValues(); //Loops through range results for (var i in rangevalues) { for (var j in rangevalues) { //Get the x,y location of the current cell. var x = parseInt(j, 10) + 1; var y = parseInt(i, 10) + 1; //Set the rules logic if (rangevalues[i][j] == 1) { //Set the cell background sheet.getRange(y,x).setBackground("green"); sheet.getRange(y,x).setFontColor("white"); } } } } function openURL(){ var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("n-gadget"); var link = sheet.getRange("C3:C").getValue(); var title = sheet.getRange("B3:B").getValue(); showAnchor(title,link); } function showAnchor(name,url) { var html = '<html><body><a href="'+url+'" target="blank" onclick="google.script.host.close()">'+name+'</a></body></html>'; var ui = HtmlService.createHtmlOutput(html) SpreadsheetApp.getUi().showModelessDialog(ui,"check stats"); }
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Acabo de encontrar la solución:

 var link = sheet.getRange(y,x+2).getValue(); var title = sheet.getRange(y,x+1).getValue();

Aquí está el código completo (la validación de datos es 1 y 0 en lugar de VERDADERO o FALSO):

 function processSelectedRows() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("n-gadget"); var rows = SpreadsheetApp.getActiveSpreadsheet().getDataRange().getValues(); var headers = rows.shift(); rows.forEach(function(row) { if(row[0]) { Logger.log(JSON.stringify(row)); setCellColors(); } }); } function setCellColors() { //Get the sheet you want to work with. var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName("n-gadget"); //Grab the entire Range, and grab whatever values you need from it. EX: rangevalues //if lower cell is set highlight will move upward var range = sheet.getRange("A1:A"); var rangevalues = range.getValues(); //Loops through range results for (var i in rangevalues) { for (var j in rangevalues) { //Get the x,y location of the current cell. y is row x is column var x = parseInt(j, 10) + 1; var y = parseInt(i, 10) + 1; //var link; //var title; //Set the rules logic if (rangevalues[i][j] == 1) { //Set the cell background //test location //sheet.getRange(y,x+3).setValue('OK'); var link = sheet.getRange(y,x+2).getValue(); var title = sheet.getRange(y,x+1).getValue(); //title.getText(x+1); sheet.getRange(y,x).setBackground("green"); sheet.getRange(y,x).setFontColor("white"); showAnchor(title,link); range.clear(); } } } } function showAnchor(name,url) { var html = '<html><body><a href="'+url+'" target="blank" onclick="google.script.host.close()">'+name+'</a></body></html>'; var ui = HtmlService.createHtmlOutput(html) SpreadsheetApp.getUi().showModelessDialog(ui,"check stats"); }

ver la salida

PD: Esto todavía tiene agujeros de bucle como si se marcaran varias casillas de verificación (se agregó la función de borrado de rango), por lo que todavía estoy abierto a sugerencias o ajustes.

about 4 years ago · Santiago Gelvez 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