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

95
Views
Problem with getvalues methods in range class

I'm trying to create a script to check if all the values in a range of rows are unique usig google app scripts.

function verficarCodUnico(){
  let ss = SpreadsheetApp.getActive();
  let sheet = ss.getActiveSheet();
  let lastRow = sheet.getMaxRows();
  let frozenRows = sheet.getFrozenRows();
  let fCol = sheet.getRange(frozenRows+1,1,lastRow).getValues();
  //this range created with to more lines than it should, so:
  fCol.length = fCol.length -2;
  
  
  let repeated = [];
  let aux = fCol.filter(function(elemento, i) {
    if(fCol.indexOf(elemento) !== i) {
        repeated.push(elemento)
    }
    return fCol.indexOf(elemento) == i;  

this code should work but the fCol array is been created as a array of arrays fCol = [[1],[123],[2],[123]] but what i want is fCol = [1,123,2,123]

I could fix the problem with

let fCol2 = [];
  for (i in fCol){fCol2.push(fCol[i][0])}

I looked in the google app script api, and i undestood that getValues should return the values of the range. Or I am wrong?

print from google app script help page

about 4 years ago · Juan Pablo Isaza
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!