Google Apps Script Propertiesservice - Confused By Unreliable Executions Logging & Editor Debugging
I find PropertiesService to be unreliable, but probably I'm just not familiar with Google Apps Script or Stackdriver and made a mistake or assumed something here that may caused th
Solution 1:
For relatively better and reliable logging, Use Stackdriver directly(i.e., View> Stackdriver logging) rather than from the "executions" page in the dashboard. To do this, you need to switch Google cloud project from default to standard by setting a custom project number in Resources > Cloud Platform project > Change project.
When logging objects, You must always
JSON.stringify
the object before feeding it toconsole
.props.toString()
will only return[object Object]
as that is it's internal structure.
/*<ignore>*/console.config({maximize:true,timeStamps:false,autoScroll:false});/*</ignore>*/const props = {a:1};
console.log(props.toString());//[object Object]console.log(JSON.stringify(props));//{"a":1}
<!-- https://meta.stackoverflow.com/a/375985/ --><scriptsrc="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
Solution 2:
This seems to work just fine:
functiontestprops() {
let sp = PropertiesService.getScriptProperties();
sp.setProperties({'somekey': Utilities.formatDate(newDate(), Session.getScriptTimeZone(), "yyyy:MM:dd HH:mm:ss")});
let props = sp.getProperties();
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(props.somekey), "View Properties");
}
Post a Comment for "Google Apps Script Propertiesservice - Confused By Unreliable Executions Logging & Editor Debugging"