1
votes

I have a problem passing parameters from a doget() to a template im using with Google Apps Script. Here's an code excerpt:

The .gs file:

  function doGet(request) {
  var t = HtmlService.createTemplateFromFile('index');
  t.line = findCell(request)
  t.parameters = request
  return t.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

The .html file:

 <?= parameters.id ?>

If I then go to this URL (of the actual app) https://script.google.com/a/macros/bucerius-alumni.de/s/AKfycbwvpTfB8KeMIUex4XUiWyI5qHfDbrNb-ZUHbgFJcsikFjuRo9WV/exec?id=1 and pass the parameter id=1 it renders out 'undefined'.

I don't really get it. Can anybody help me please? :-)

Thank you all Alex

1
Have you tried if it works with HtmlService.SandboxMode.NATIVE instead of IFRAME?Dayton Wang

1 Answers

1
votes

URL parameters are received in doGet under a "parameter" property of the first function parameter, in your case request. So, it would be request.parameter.id. Or in your html parameters.parameter.id.

To see all the parameters you receive and their structure, change your html to:

<?= JSON.stringify(parameters) ?>