0
votes

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?

2
In your situation, when your Web Apps is redeployed as new version and test it again, your situation will be changed? - Tanaike
Doesn't help. The problem stays the same. - Thorsten Liewald
Thank you for replying. I deeply apologize my comment was not useful for your situation. - Tanaike
For the back end code, try using the === instead of the == operator. Also, if nutzerSquad is 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
Anything has changed? Can you share a copy of the sheet and the web app (with dummy data if needed) to try to reproduce it? - Kessy

2 Answers

0
votes

It looks like you are declaring your Back End code variable twice

function getDropDownArray(){
  var arrDevLogic = ssAssessmentLogic.getDataRange().getValues();
  **var** arrDevLogic =arrDevLogic.filter(function (dataRow) {return dataRow[5] == nutzerSquad})
  return arrDevLogic;

What if you deleted the second declaration...

function getDropDownArray(){
  var arrDevLogic = ssAssessmentLogic.getDataRange().getValues();
      arrDevLogic =arrDevLogic.filter(function (dataRow) {return dataRow[5] == nutzerSquad})
  return arrDevLogic;
0
votes

it seems I found the solution. In the Array of Arrays some fields in the "row Array" were a date while other were blank. It seems that the HTML Part of the code didn't like it when some of the arrays had a date value and some were blank.

Thanks everybody for the help.