google apps script - OpenByUrl throwing error: You do not have permission to call openByUrl (line 39, file "Code") -
i have script in google spreadsheet opens google doc , returns text in cell of table, follows:
function getitemstatus(docurl) { var doc = documentapp.openbyurl(docurl); var docbody = doc.getbody(); var doctbls = docbody.gettables(); var itmtbl = doctbls[0]; var itmstatus = itmtbl.getcell(3,1).gettext(); return itmstatus; }
when attempt run function in spreadsheet, returns error:
error: not have permission call openbyurl (line 39, file "code")
if create function call above function directly works fine , returns value after.
function testitemget() { var docurl = ("..."); itmstr = getitemstatus(docurl); logger.log("the item's value " + itmstr) }
resulting log file:
[13-07-17 19:27:39:130 edt] starting execution
[13-07-17 19:27:39:387 edt] documentapp.openbyurl([...]) [0.253 seconds]
[13-07-17 19:27:39:388 edt] document.getbody() [0 seconds]
[13-07-17 19:27:39:388 edt] body.gettables() [0 seconds]
[13-07-17 19:27:39:388 edt] table.getcell([3, 1]) [0 seconds]
[13-07-17 19:27:39:389 edt] tablecell.gettext() [0 seconds]
[13-07-17 19:27:39:389 edt] logger.clear() [0 seconds]
[13-07-17 19:27:39:389 edt] logger.log([the item's value deferred , []]) [0 seconds]
[13-07-17 19:27:39:390 edt] execution succeeded [0.256 seconds total runtime]
from have googled, long have edit or owner rights document should able this.
i pretty new google apps scripting please gentle. :)
thank ahead of time , patience!
custom functions run limited permissions, , cannot take advantages of services rely on user credentials, including documentapp.
https://developers.google.com/apps-script/execution_custom_functions#permissions
Comments
Post a Comment