With a file structure in Google Apps Script like:
- code.gs
- page.html
where code.gs serves page.html with doGet
Are the script properties available to the javascript inside the <script>
tags in page.html?
If so, how would I access them?
With a file structure in Google Apps Script like:
where code.gs serves page.html with doGet
Are the script properties available to the javascript inside the <script>
tags in page.html?
If so, how would I access them?
Agree w/ comment. There is probably no direct way, so this works ok.
// server-side
function getProperties(){
const properties = PropertiesService.getScriptProperties().getProperties();
return JSON.stringify(properties)
}
// client-side
function getPropertiesFromServer(){
google.script.run.withSuccessHandler(processProperties).getProperties()
}
function processProperties(propertiesText){
const properties = JSON.parse(propertiesText)
...
}
Comment:
PropertiesService only available on server side. But you could the the entire object return to you with google.script.run.withSuccessHandler().functionName(); – Cooper