Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

459
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!