In my Google Apps Script App I am seeing the following error:
The script completed but the returned value is not a supported return type
How can I find out the type of the value which I am returning? I tried:
typeof(obj)
But all I get told is that it is an Object.
This error only occurs when the cache is empty and the data is loaded from a spreadsheet. E.g. User hits the page, the get the error, a refresh now loads the page as the cache was populated on the first hit. Now users can continue using the page until the cache is invalidated, then the next hit will cause this error again.
This error started happening today after I read and followed this document. Previously my script was loading data in the template, I have now refactored to load asynchronously using:
google.script.run
I took a look at what was happening in my page as to why it worked when read from cache and the only thing I could see different was that data in the cache had been parsed from a JSON string. When the cache is empty I have to stringify the object in order to save into the cache, so rather than returning my original object, I then parse the string I just created and return that and now there is no error.
I'm not sure where the error is coming from either, is it Apps Script or is it Caja?
Parsing the JSON string back in order to return is not the ideal solution either, what is this stringifying / parsing doing to my original object that removes the error?
When I use the built in debugger to inspect the objects (before and after the stringifying / parsing process) the values and types all seem to be identical to the best of my ability to check.
Is this a bug in Apps Script? Am I doing something wrong? What is the best solution to remove this error?
5:58:02 PM Info Spreadsheet: obj.getObjTypeXYZZY is not a function
5:58:02 PM Info Sheet: obj.getObjTypeXYZZY is not a function
5:58:02 PM Info Range: obj.getObjTypeXYZZY is not a function
5:58:02 PM Info String: string
– Arson