Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda