I having a project where I am using a Google Sheet as a Database with a Web App as frontend.
Until yesterday a data array passed from the backend to the front end but it doesn't work anymore. The logger.log in the backend shows that we have an array. But the front end never receives the data.
Back End Code (ssAssessmentLogic is a datasheet)
function getDropDownArray(){
var arrDevLogic = ssAssessmentLogic.getDataRange().getValues();
var arrDevLogic =arrDevLogic.filter(function (dataRow) {return dataRow[5] == nutzerSquad})
return arrDevLogic;
Front End Code:
function afterPageLoads(){ //Loads the Dropdowns. First gets the data from the spreadsheet and then populates the dropdowns with the array
google.script.run.withSuccessHandler(afterDataArrayReturned).getDropDownArray();
}
function afterDataArrayReturned(arrDevLogic){ //after the array withe the data came back from the sheet, store the data in a global html variable and pass it to the function to fill the drodown
console.log(arrDevLogic);
arrayOfValues = arrDevLogic.filter(function(r){return true;});
var item = document.getElementById("sdp_ms");
addUniqueDropdown(item, arrayOfValues, 4);
}
While loading the html page I get an error that the filter of null doesn't work and it shows the console log value as null. If I run just the backend function it proviedes me an array of array with 260 items in it.
Can somebody please help me spot the problem?
===instead of the==operator. Also, ifnutzerSquadis meant to be a string be sure to enclose it in quotes. If its a variable, then you might want to check its value (I'm assuming its set globally), that equality test could be turning up false for every row, in which case you'll end up with an empty array once its filtered. - TheAddonDepot