G
You're overlooked. getValues() returns a matrix (we can also call it vector, two-dimensional Array among other forms)In fact, the record gives you clues about it when Logger.log('ÀCA SE ENCUENTRA', datosOriginales[55]); write [23?57] (the brackets indicate that it is a vector, and since there are no commas, it contains an element)In terms of spreadsheet, instead of "vector" as the one shown as a result of Logger.log(datosOriginales); used column and position we refer to as row, then, we can say that what you're looking for is to find the row in which it is found 23?57 in the Column A.A simple way is to use a loop and for it the most common one is forfunction myFunctionIndexOF() {
var EquiposStock = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName("EquiposStock");
var datosOriginales = EquiposStock.getRange(2, 1, EquiposStock.getLastRow(), 1)
.getValues();
var filtro = '23?57';
// var pos = datosOriginales.indexOf('23?57');
var filas = datosOriginales.length;
for(var fila = 0; fila < filas; fila++){
if( datosOriginales[fila][0] === '23?57') break;
}
Logger.log('ÀCA SE ENCUENTRA', datosOriginales[55]);
// Logger.log('POSICION',pos);
Logger.log('POSICION', fila);
Logger.log(datosOriginales);
}
Note that the Array indices in Google Apps Script/JavaScript are base 0 and that the row numbering of the Google spreadsheet is base 1. Depending on the use you will give to the "position" you would have to adjust the row number considering that the data has been taken from row 2.You can use other loops and even methods of Array