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

468
Vistas
How I can solve this error in setValues function "The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues"

I'm pre-filling a Google form with AppScript, finally I'm saving the urls in an array.

var formCol = SpreadsheetApp.getActive().getRangeByName('FORM');
var form = FormApp.openByUrl(FORM_URL);
var items = form.getItems();

var urls = [];
for (let i = 1; i < 4; i++ ) {
    
    var formResponse = form.createResponse();

    var formItem = items[0].asTextItem();
    response = formItem.createResponse(botData.id[i]);
    formResponse.withItemResponse(response);

    formItem = items[1].asTextItem();
    response = formItem.createResponse(botData.bot[i]);
    formResponse.withItemResponse(response);

    var date = new Date (botData.date[i].toString());
    var date2 = botData.date[i].toString();
    
    //var day
    formItem = items[3].asTextItem();
    response = formItem.createResponse(botData.zone[i]);
    formResponse.withItemResponse(response);

    formItem = items[8].asTextItem();
    response = formItem.createResponse(botData.remitent[i]);
    formResponse.withItemResponse(response);

    formItem = items[9].asTextItem();
    response = formItem.createResponse(botData.description[i]);
    formResponse.withItemResponse(response);

    formItem = items[11].asTextItem();
    response = formItem.createResponse(botData.solutiontime[i]);
    formResponse.withItemResponse(response);


    var url = formResponse.toPrefilledUrl();
    //sheet.getRange(row, 31).setValue(url);
    url = url.toString()
    urls.push(url)
    
  }
  formCol.setValues(urls);
}

I want to print each url in a 'FORM' column of Google Sheets but I get the error "
Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues." when I try to print the array with setValues, how I can solve this error?

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

0

Modification points:

  • In your script, urls of formCol.setValues(urls) is 1 dimensional array. The argument of setValues(value) is required to be 2 dimensional array.
  • When your range of var formCol = SpreadsheetApp.getActive().getRangeByName('FORM'); is used, the size of the range cannot be known. So, in your situation, it might be required to modify the range for putting the values of urls.

When these points are reflected in your script, it becomes as follows.

Modified script:

From:

  urls.push(url)
  
}
formCol.setValues(urls);

To:

  urls.push([url]);
}
formCol.setValues(urls);

or

  urls.push([url]);
}
formCol.offset(0, 0, urls.length, 1).setValues(urls);

References:

  • setValues(values)
  • offset(rowOffset, columnOffset, numRows, numColumns)
about 4 years ago · Juan Pablo Isaza Denunciar

0

It looks like you are passing an argument that is of the wrong type for the setValues function. According to the documentation, you should pass a two dimensional array.

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