user3465659
user3465659

Reputation: 21

Google Appscript:Uncaught ScriptError: The script completed but the returned value is not a supported return type

I have searched everywhere on here and all over Google and have run into similar issues but the solutions have not helped me out. I am still getting the "Uncaught ScriptError: The script completed but the returned value is not a supported return type." even though the Logger.log information looks perfectly fine, but when it is served to my index.html file, it comes with the error. Please advise. Below are my codes to generate the data from a spreadsheet the returns a Logger.log of an object of exactly what I want, but doesn't seem to come through as a return type on the index.html file. Also, this is a WebApp that I have created. It ask for a spreadsheet URL from the user and uses that url to parse the data from the spreadsheet. I've modified it so that it includes a URL that returns the "unsupported" data. I'm hoping someone will see a syntax error something before I have to share any spreadsheet information.

 function getData(){

  var url = "https://docs.google.com/spreadsheets/d/1ZfWLpEoID85RCsDLiVP04ENuhaYT6KUSPViR4fsEsdk/edit;

  var ss = SpreadsheetApp.openByUrl(url).getSheets()[0];

  var data = ObjApp.rangeToObjects(ss.getDataRange().getValues());


  var object = [];
  for(var i=0; i < data.length; i++) {
object.push([
              data[i].observer,
              Utilities.formatDate(new Date(data[i].date),Session.getScriptTimeZone(),"MM/dd/yyyy").toString(),
              data[i].scriptevidence,
              data[i].domain1PlanningPreparation,
              data[i].domain2ClassroomEnvironment,
              data[i].domain3Instruction,
              data[i].domain4ProfessionalResponsibilities]); 

}

  Logger.log(object); //the logger is perfectly what I want

  return object; //not supported according to the console

}

I'd appreciate any advice. Thank you in advance.

EDIT: Solved the issue by wrapping each of my iterated data and turning it into a string.

 (data[i].observer).toString(),
              Utilities.formatDate(new Date(data[i].date),Session.getScriptTimeZone(),"MM/dd/yyyy").toString(),
              (data[i].scriptevidence).toString(),
              (data[i].domain1PlanningPreparation).toString(),
              (data[i].domain2ClassroomEnvironment).toString(),
              (data[i].domain3Instruction).toString(),
              (data[i].domain4ProfessionalResponsibilities).toString()]); 

Upvotes: 1

Views: 1454

Answers (1)

Marc Perrin-Pelletier
Marc Perrin-Pelletier

Reputation: 13456

I ran into this problem as well. In the end it was a date problem. Just like you, putting it my data in a string via JSON.stringify solved my problem.

Upvotes: 0

Related Questions