I am trying to create a custom side menu to use as a filter and edit tool for data on the spreadsheet. I have the html and css down but Ive hit a snag on filtering array data from getRangevalues filtering.
{
const {google, containeranalysis_v1alpha1} =
require('googleapis');
const keys = require('./key.json');
const client = new google.auth.JWT(
keys.client_email,
null,
keys.private_key,
['https://www.googleapis.com/auth/spreadsheets']
);
async function gsrun(cl){
const gsapi = google.sheets({version:'v4', auth: cl});
const opt = {
spreadsheetId: 'XXXXXXXX',
range: 'Data!A1:G'
};
let data = await gsapi.spreadsheets.values.get(opt);
let dataArray = data.data.values;
let newArray = dataArray.filter(function(checkDate){
return checkDate === '09/16'; });
console.log(newArray);
};
I am just trying to get a functional filter and then my next goal is to apply the filter parameters via html datePicker menu
*Edit| this is my script I was working on in node.j using an api. no appscript, but is essentially the same
I am still having trouble getting the array to function after applying the filter. im not getting any errors but i am also not getting any return values.
Date Patient Name PO Claim Submitted Frame Lens Status 09/15 xxxx xxxx PP Yes No Lens on Order 09/15 xxxx xxxx Yes Lens on Order 09/13 xxxx xxxx PP No No Frame & Lens on Order 09/16 xxxx xxxx Yes Frame & Lens on Order 09/16 xxxx xxxx Yes Frame & Lens on Order 09/16 xxxx xxxx Yes Yes No Lens on Order 09/16 xxxx xxxx NA No No Frame & Lens on Order 09/21 xxxx xxxx Yes No No Frame & Lens on Order 09/12 xxxx xxxx PP Yes No Lens on Order
this is the sheet. I am trying to filter this by date and then return all entire rows meeting the criteria
You are not handling a 2d array properly.
const dateColIndex = 0;
let newArray = dataArray.filter(function(row){
return row[dateColIndex].getTime() === new Date('2021/09/16').getTime(); });