1
votes

Is it possible to include parameters in a URL referencing a shared Google Sheet?

A typical URL will look like this: https://docs.google.com/spreadsheets/d/1c-sxi4cwZXUXTHJSU-Nzl1lAwPCs123l46UKQgABCp0/edit#gid=1455048586

What I'm trying to do is include a parameter, something like: https://docs.google.com/spreadsheets/d/1c-sxi4cwZXUXTHJSU-Nzl1lAwPCs123l46UKQgABCp0/edit#gid=1455048586?msg=Hello

I then would hope to retrieve the value of msg with the doGet(e) function which includes the following line, just to prove it works.

SpreadsheetApp.getUi().alert(e.parameter.msg);

If the following solution is the best alternative, I'll change course: Google spreadsheet reading parameters from its own URL

1
I'm afraid the answer will be the same as in September 2014, you just can't add custom parameters to a spreadsheet URL since there is no way to retrieve it.Serge insas

1 Answers

0
votes

Adding parameters to spreadsheet URL will not do anything for doGet function. The function doGet does not run when someone opens the spreadsheet. To use it, the script must be deployed as a web app, after which this web app is given its own URL, different from spreadsheet URL. To that URL you can add URL parameters:

https://script.google.com/macros/s/..../exec?msg=Hello

and then e.parameter.msg in doGet will indeed be "Hello", as described in URL parameters article.