0

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?

Rubén
  • 34,714
  • 9
  • 70
  • 166
kztd
  • 3,121
  • 1
  • 20
  • 18
  • 1
    PropertiesService only available on server side. But you could the the entire object return to you with `google.script.run.withSuccessHandler().functionName();` – Cooper Nov 27 '22 at 22:49
  • Please show what you have tried and add a brief description of your search efforts as is suggested in [ask]. – Rubén Nov 28 '22 at 01:08

1 Answers1

1

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

kztd
  • 3,121
  • 1
  • 20
  • 18
  • Comments might be deleted at any time. If the referred comment is relevant, add it to the answer providing the proper attribution. – Rubén Nov 28 '22 at 02:10