craftApprentice
craftApprentice

Reputation: 2777

GAS openByUrl() error: invalid argument: url

Why does this code:

var target = createDuplicateDocument(template, docName);
var targetDocId = target.getId();
var link = target.getUrl();
var myVariable = DocumentApp.openByUrl(newDocLink).getText();

produce this error?

14-02-01 11:02:37:973 BRST] DocumentApp.openByUrl([https://docs.google.com/open?id=1kQWDgh7Qe80pCuvs2VQjPhJGCSk9KXXXs4Nqt2pLH1c]) [0 segundos]
[14-02-01 11:02:38:931 BRST] Falha na execução: Argumento inválido: url (line 238, file "mainScript") [2.796 segundos de tempo de execução total]

I also tried var myVariable = DocumentApp.openByUrl(newDocLink[0]).getText(); and it didn't work. I know I could use openById, but I want get openByUrl working. Thanks!

Upvotes: 2

Views: 1696

Answers (1)

carpiediem
carpiediem

Reputation: 2038

newDocLink is never defined above where it is used as an argument.

Upvotes: 1

Related Questions