Reputation: 109
I need to get url address of current Spreadsheet by script without fixed address like this
let curURL = "https://docs.google.com/spreadsheets/d/1mCcmko-FvmTTJn8RDhlfWE0AZYPKlUnskqlc4-eYrJ4/edit?usp=sharing";
I tried to use this
let curURL = ScriptApp.getService().getUrl();
but I got empty value. Thank you for help!
Upvotes: 1
Views: 209
Reputation: 201613
In order to retrieve the URL like https://docs.google.com/spreadsheets/d/###/edit?usp=sharing
, if you are using the container-bound script of Google Spreadsheet, how about the following sample script?
let curURL = SpreadsheetApp.getActiveSpreadsheet().getUrl() + "?usp=sharing";
If you are not required to use ?usp=sharing
, please remove it.
If your script is not container-bound script, how about the following script?
const spreadsheetId = "###";
let curURL = `https://docs.google.com/spreadsheets/d/${spreadsheetId}/edit?usp=sharing`;
Upvotes: 1