0

In google spreadsheet I see in the address bar that my doc url is https://docs.google.com/spreadsheet/ccc?key=0AuQ7FOvczgvFdHVzRXFKLTF1dHM5dk1qR1VzNGFDNGc#gid=0

However, when I write Browser.msgBox(SpreadsheetApp.getActiveSpreadsheet().getUrl()); in the script I get the following url
https://docs.google.com/spreadsheet/ccc?key=tusEqJ-1uts9vMjGUs4aC4g

Why is there a discrepancy? Which one should I be using for my integrations?

1 Answer 1

2

Turns out Google keeps different IDs for the spreadsheet and for the document entity and the one displayed in the address bar is the doc id.

So if you want to get the doc id you should do the following:

var file = DocsList.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId());
Browser.msgBox(file.getId());

Hopefully this will help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.