0
votes

I'm programming a Google script for a spreadsheet, and after deploying it as web app, you get an URL (https://script.google.com/macros/s/.../dev).

I would like pass an input parameter in the URL (e.g. (https://script.google.com/macros/s/.../dev/param).

How can I fetch the value of this parameter in the script?

1
To get the current url in JS you can use document.URL does google allow you to add extra parameters and still direct to your script? - Quince
DocumentApp.getActiveDocument().getUrl() would return the URL, but for some reason this is not working, so I can't try with extra parameters. - nightcod3r
Just to make my point clearer: I'm working with a deployable script, what I'm trying to do is in the scope of a doGet() function. - nightcod3r
ah is your script sandboxed? not used js on a google spreadsheet before - Quince
actual just read this stackoverflow.com/a/14132977/2737978 which states that you can't get any useful information from the url - Quince

1 Answers

1
votes

you can add a string at the end of the deployed webapp url, just insert a question mark and separate arguments with &.

example :

the .dev     https://script.google.com/macros/s/AKfycb___vWxs/dev?val=test&otherVal=otherTest

the .exec    https://script.google.com/macros/s/AKfycb___vWxs/exec?val=test&otherVal=otherTest

demo code :

function doGet(e) {
  var valToReturn = ContentService.createTextOutput('the parameters were '+e.parameter.val+'\nand\n'+e.parameter.otherVal).setMimeType(ContentService.MimeType.TEXT);
  return valToReturn;
}

You'll get both parameter values in your browser