WAI
Status Update
Comments
sz...@nestlabsarchive.com <sz...@nestlabsarchive.com> #2
For the avoidance of doubt, if I create a function
function myFunction() {
Library.libFunction1();
}
and then run myFunction, that works fine.
function myFunction() {
Library.libFunction1();
}
and then run myFunction, that works fine.
li...@gmail.com <li...@gmail.com> #3
Yes, libFunction1 - library function should be called directly from the menu, not from the upper level script. Currently it works in next way:
-----------LIB-----------
function libMenu() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "libFunction1", functionName: "Library.libFunction1"},
{name: "libFunction2", functionName: "libFunction1"}
];
mySheet.addMenu("Library Functions", menuEntries);
}
-----------LIB-----------
-----------CLIENT-----------
function onOpen() {
Library.libMenu();
}
function libFunction1() {
Library.libFunction1();
}
-----------CLIENT-----------
but client script should contain only onOpen function.
-----------LIB-----------
function libMenu() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "libFunction1", functionName: "Library.libFunction1"},
{name: "libFunction2", functionName: "libFunction1"}
];
mySheet.addMenu("Library Functions", menuEntries);
}
-----------LIB-----------
-----------CLIENT-----------
function onOpen() {
Library.libMenu();
}
function libFunction1() {
Library.libFunction1();
}
-----------CLIENT-----------
but client script should contain only onOpen function.
mu...@gmail.com <mu...@gmail.com> #4
[Comment deleted]
[Deleted User] <[Deleted User]> #5
When you plan to fix it? It's very important issue. Thanks.
ko...@gmail.com <ko...@gmail.com> #8
Yes, a big inconvenience. One way to circumvent it could be to call a master libfuntion in the client, with a parameter:
function libFunction1(menuitem) {
Library.libFunction1(menuitem);
}
but... menuitems do not accept parameters.
So, my second choice will be to populate my client script (which should ideally only contain onOpen) with a number of "generic" menu function triggers, some of them just sitting there, ready for future expansions, hopefully enough so that I will never have to alter the client script when i expand the library with more menu items, and at the same time not having misleading names (not descriptive either, unfortunately):
function libFunction1() {
Library.libFunction1();
}
function libFunction2() {
Library.libFunction2();
}
...
function libFunction20() {
Library.libFunction20();
}
function libFunction1(menuitem) {
Library.libFunction1(menuitem);
}
but... menuitems do not accept parameters.
So, my second choice will be to populate my client script (which should ideally only contain onOpen) with a number of "generic" menu function triggers, some of them just sitting there, ready for future expansions, hopefully enough so that I will never have to alter the client script when i expand the library with more menu items, and at the same time not having misleading names (not descriptive either, unfortunately):
function libFunction1() {
Library.libFunction1();
}
function libFunction2() {
Library.libFunction2();
}
...
function libFunction20() {
Library.libFunction20();
}
br...@gmail.com <br...@gmail.com> #9
Instead of passing a functionName, why not passing the function itself?
e.g.,
-----------LIB-----------
function libMenu() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "menuItem1", handler: menuItem1},
{name: "libFunction2", handler: function() {menuItem2(3);}}
];
mySheet.addMenu("Library Functions", menuEntries);
}
function menuItem1() {
}
function menuItem2(someArg) {
}
-----------LIB-----------
-----------CLIENT-----------
function onOpen() {
Library.libMenu();
}
-----------CLIENT-----------
e.g.,
-----------LIB-----------
function libMenu() {
var mySheet = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "menuItem1", handler: menuItem1},
{name: "libFunction2", handler: function() {menuItem2(3);}}
];
mySheet.addMenu("Library Functions", menuEntries);
}
function menuItem1() {
}
function menuItem2(someArg) {
}
-----------LIB-----------
-----------CLIENT-----------
function onOpen() {
Library.libMenu();
}
-----------CLIENT-----------
dr...@gtempaccount.com <dr...@gtempaccount.com> #10
Without this feature, libraries are really nobbled!
+1 for passing the function itself!
+1 for passing the function itself!
br...@gmail.com <br...@gmail.com> #12
Please Fix it.
dr...@gtempaccount.com <dr...@gtempaccount.com> #13
I actually thought cooledco's suggestion was a current solution to the problem, but alas it is just a suggestion to how a possible solution might be implemented.
+1 for the idea though. This passing of function "names" seems very old skool!?
+1 for the idea though. This passing of function "names" seems very old skool!?
ko...@gmail.com <ko...@gmail.com> #16
A year later and this has been ignored?? What is the point of having a global library if you have to write a freaking wrapper for it each time?! The mind boggles. Please fix this, it should be callable from both the spreadsheet cells AND any buttons (images -> via assign script) on the spreadsheet that has the library included.
cr...@gmail.com <cr...@gmail.com> #17
I, too, have been forced to constantly edit my client scripts any time I want to make changes to the Library. I came across this post as I was looking for a solution, but it looks like there really is no convenient solution at the moment. That would be very nice if there were.
+1 for calling a library function directly from the menu
+1 for calling a library function directly from the menu
sa...@gmail.com <sa...@gmail.com> #18
to me works SpreadsheetApp.getUi().createMenu('MenuName').addItem('ItemName', 'Library.libFunction1').addToUi();
cr...@gmail.com <cr...@gmail.com> #19
Here is a workaround that allows you to call any library function if you paste in this one generic wrapper function. Then you can call this from the spreadsheet.
For example, if I had a library called MyLib with a function add(x, y) (pretend x is in cell A1 and y is in cell A2) I could call it like this:
=LIB_FUNC("MyLib", "add", A1, A2).
It's a little ugly but at least allows me to only have to paste this one function and then access any library function. Note that this depends on undocumented structure of the "this" object that is in scope when calling the wrapper function. Small chance this could break over time. Might see if I can publish this as an add on.
function LIB_FUNC(libraryName, functionName) {
var result;
var lib = this[libraryName];
var extraArgs = [];
if (lib) {
var func = lib[functionName];
if (func) {
if (arguments.length > 2) {
extraArgs = Array.apply(null, arguments).slice(2);
}
result = func.apply(this, extraArgs);
} else {
throw "No such function: " + functionName;
}
} else {
throw "No such library: " + libraryName;
}
return result;
}
For example, if I had a library called MyLib with a function add(x, y) (pretend x is in cell A1 and y is in cell A2) I could call it like this:
=LIB_FUNC("MyLib", "add", A1, A2).
It's a little ugly but at least allows me to only have to paste this one function and then access any library function. Note that this depends on undocumented structure of the "this" object that is in scope when calling the wrapper function. Small chance this could break over time. Might see if I can publish this as an add on.
function LIB_FUNC(libraryName, functionName) {
var result;
var lib = this[libraryName];
var extraArgs = [];
if (lib) {
var func = lib[functionName];
if (func) {
if (arguments.length > 2) {
extraArgs = Array.apply(null, arguments).slice(2);
}
result = func.apply(this, extraArgs);
} else {
throw "No such function: " + functionName;
}
} else {
throw "No such library: " + libraryName;
}
return result;
}
le...@gmail.com <le...@gmail.com> #20
Just in case people are still looking for solutions.
function TESTF() {
return myLib.TESTF.apply(null,arguments);
}
Can be applied in a for loop for every method on myLib.. I use this in all of my scripts so I just have a 5 line script in the document, add the library, and walah, the library is directly part of this script as if I was "using namespace myLib;"
[edit] Also, this means that spreadsheets can call those functions as well as if they were actually written in this script.
Hope it helps.
function TESTF() {
return myLib.TESTF.apply(null,arguments);
}
Can be applied in a for loop for every method on myLib.. I use this in all of my scripts so I just have a 5 line script in the document, add the library, and walah, the library is directly part of this script as if I was "using namespace myLib;"
[edit] Also, this means that spreadsheets can call those functions as well as if they were actually written in this script.
Hope it helps.
le...@gmail.com <le...@gmail.com> #21
Comment 20 explanation is a little opaque to me. Can anyone elaborate?
Seems silly that library functions aren't exposed to the documents once included. Makes them somewhat pointless if a wrapper must be included in every document, or unless #20 is on to something with a generic 5 line wrapper.
Seems silly that library functions aren't exposed to the documents once included. Makes them somewhat pointless if a wrapper must be included in every document, or unless #20 is on to something with a generic 5 line wrapper.
km...@dillon.ca <km...@dillon.ca> #22
I am also interested in a deeper explanation of comment #20
I understand she/he meants using a loop to navigate all methods in library, in order to easily define a new function inside the sheet-bounded-script for each library method.
But, how can we loop every method on the library? And how can we define a new function inside that loop, which takes its name from the library?
I understand she/he meants using a loop to navigate all methods in library, in order to easily define a new function inside the sheet-bounded-script for each library method.
But, how can we loop every method on the library? And how can we define a new function inside that loop, which takes its name from the library?
[Deleted User] <[Deleted User]> #23
same here, please explain if possible !
ev...@embarcchicago.org <ev...@embarcchicago.org> #24
As far as I can tell, calling library functions from menus as in SpreadsheetApp.getUi().createMenu('MenuName').addItem('ItemName', 'Library.libFunction1').addToUi() has been supported since 2013. I don't see any additional work that needs to be done here.
da...@andante.be <da...@andante.be> #25
Judging by the comments in the thread, I believe the expectation is that functions in a Library could be called from not only a menu item, but also from the Sheet's own script, and even directly from a formula entered in a cell, just like any other function local to the Sheet's script would be called, only difference being that the referred function would be in the Library.
fa...@gmail.com <fa...@gmail.com> #26
This is indeed a big problem. After DAYS trying to use IMPORTRANGE and ARRAYFORMULA for generating a column which repeats a "title" from other cell beside every imported line, I thought that the only way I could do it would be using Apps Script. So I went on trying to learn the whole thing, having to learn JavaScript (it's a shame that Google's documentation *requires* that you know JS previously), and then I find that it also will not be possible.
At least if we could use the built-in formulas in the scripts, ok, we might deal with IMPORTRANGE's limitations. But this is another big issue in Google Sheets. A workaround, please...
At least if we could use the built-in formulas in the scripts, ok, we might deal with IMPORTRANGE's limitations. But this is another big issue in Google Sheets. A workaround, please...
al...@holubec.net <al...@holubec.net> #27
[Comment deleted]
al...@holubec.net <al...@holubec.net> #28
I'm totally frustrated, I have GAS code used over 5 years to support all CRM relations in our non government organisation. I developed and used libraries which build over Spreadsheets object data layer, so all application functionality is accessing data from sheets via that layer. It means that it is simple to add, modify, reallocate columns or change cell functions without code changes or knowledge of column names, only change in configuration sheet is necessary. And now without possibility to open second sheet form code in first sheet a have to again merge all data to one big spreadsheet, which is almost impossible due to limitation in cut & paste functionality. Thankx google... I'm going to move to other solution where I will have lifecycle in code in my hands :-(
ma...@gmail.com <ma...@gmail.com> #29
Why would Google change something so important like this at such a late stage of the product life cycle? This is surely stuff that should have been decided on before release and before developers made all their code work using these methods?
[Deleted User] <[Deleted User]> #30
<purged>
iv...@gmail.com <iv...@gmail.com> #31
Just ran into this too and found this thread after going down many rabbit holes. Has anyone found a workaround? This seems like a major problem and it's a bit irritating that the maintainers of this code would break their API without even bothering to update the docs.
br...@gmail.com <br...@gmail.com> #32
The workaround is to use a script with a time based trigger to copy/paste your data to update. You can no longer use a custom function that auto updates with a trigger such as "on change". This works, unless you are doing very frequent triggers and start receiving the notice "using too much cpu time for one day" and then your script gets killed until the next day.
sa...@gmx.de <sa...@gmx.de> #33
Same here no permission to SpreadsheetApp.openById("abc1234567");
Please fix this!
Please fix this!
ml...@gmail.com <ml...@gmail.com> #34
Great, just wasted one day to write scripts which worked fine in script editor. But of course do not work when called from Android app, which I started developing today.
Why did you not even mention that in your documentation?
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#openById(String)
Why did you not even mention that in your documentation?
ta...@gmail.com <ta...@gmail.com> #35
[Comment deleted]
ps...@gmail.com <ps...@gmail.com> #36
Same problem trying to capture the "Edit Response" link from a Goofle Forms survey, along with the respondent's answers, in the vary Goofle Sheet that the Form is linked to.
Bad enough that this feature change wasn't preceded by any design-change logic. Even worse that it was not documented ... EVEN AFTER THE FACT.
Completely unprofessional, Goofle.
Bad enough that this feature change wasn't preceded by any design-change logic. Even worse that it was not documented ... EVEN AFTER THE FACT.
Completely unprofessional, Goofle.
ra...@quattrosolutions.com.ar <ra...@quattrosolutions.com.ar> #37
if i have 2 spreadsheet where the owner is same, why is a security problem when use SpreadsheetApp.openById() ???.
And I agree with before post (#35): "Bad enough that this feature change wasn't preceded by any design-change logic. Even worse that it was not documented ... EVEN AFTER THE FACT."
And should be careful with these types of changes that affect existing developments. In my recent experience once it allowed me to insert a row using "SpreadsheetApp.openById ()" and then gave the error "You don 't have permission to call openById". It is unclear too!
And I agree with before post (#35): "Bad enough that this feature change wasn't preceded by any design-change logic. Even worse that it was not documented ... EVEN AFTER THE FACT."
And should be careful with these types of changes that affect existing developments. In my recent experience once it allowed me to insert a row using "SpreadsheetApp.openById ()" and then gave the error "You don 't have permission to call openById". It is unclear too!
ra...@quattrosolutions.com.ar <ra...@quattrosolutions.com.ar> #38
Not work in mode read only, I need fast resolution for this issue!
ra...@quattrosolutions.com.ar <ra...@quattrosolutions.com.ar> #40
Ok, I use the method get, in read only mode but not work fine, have same error. Have u check?
"Read only (can use most get*() methods, but not set*()).
Cannot open other spreadsheets (SpreadsheetApp.openById() or SpreadsheetApp.openByUrl())."
"Read only (can use most get*() methods, but not set*()).
Cannot open other spreadsheets (SpreadsheetApp.openById() or SpreadsheetApp.openByUrl())."
md...@quantumspatial.com <md...@quantumspatial.com> #41
ok, i also wasted few hours trying to figure it out. and now i have no idea how to prepare a list of the sheetnames from the source spreadsheet.
any workaround?
any workaround?
ek...@google.com <ek...@google.com>
[Deleted User] <[Deleted User]> #42
<purged>
fa...@archlightconsulting.com <fa...@archlightconsulting.com> #43
So what is the workaround? My code references the last edited cell so a menu item really doesn't work for me
dp...@gmail.com <dp...@gmail.com> #44
without using openById, how can I write data from one spreadsheet to another? Do tell me to do it manually.
dp...@gmail.com <dp...@gmail.com> #45
By the way, I got this issue this week, it was working fine at the beginning of this week. Is that the security reasons means when google found my project is almost become a working system, then I'm not allow to use openById.
And yesterday, I'm good to save data between different files, but not today!!
And yesterday, I'm good to save data between different files, but not today!!
jo...@lighthouselabs.com <jo...@lighthouselabs.com> #46
Until last week I was able to use SpreadsheetApp.openByUrl after a user authorized an ImportRange function call to the same url. This now seems broken.
Given that a user has explicitly provided authorization for access from one spreadsheet to the other, shouldn't this be allowed?
Given that a user has explicitly provided authorization for access from one spreadsheet to the other, shouldn't this be allowed?
pu...@gmail.com <pu...@gmail.com> #47
Iam cannt believe this.
Yesterday ( 09-13-2017 ) SpreadsheetApp.openById still work it!
Today 09-14-2017, not any more.
the sentences " SpreadsheetApp.openById " , is inside a Library ! that Library, i set to run with my user (owner) and it can call for anyone ...
Why it say me that i dont have permission ??
It is castratofic and it is shame ... i cannt relies in my code anymore????
Yesterday ( 09-13-2017 ) SpreadsheetApp.openById still work it!
Today 09-14-2017, not any more.
the sentences " SpreadsheetApp.openById " , is inside a Library ! that Library, i set to run with my user (owner) and it can call for anyone ...
Why it say me that i dont have permission ??
It is castratofic and it is shame ... i cannt relies in my code anymore????
[Deleted User] <[Deleted User]> #48
Is there any update on the issue? I am working on an alternative, but I would like to know if this is going to be fixed or if it is not going to be supported anymore.
to...@gmail.com <to...@gmail.com> #49
To renew permissions with some steps:
1) Copy all your code to an editor (Ex: Notepad)
2) Go File > Delete Preject (on GAS window of the working project)
3) Return to the related Spreadsheet or Form and open Script Editor again. (A new project will be opened)
4) Paste your code in the new project
5) Run the function that access the external spreadsheet and GAS will ask again for permission to access.
If it happened on triggers, just remove the trigger and insert again that GAS will ask for permission.
Save!
Peace for all!
Racional Culture, the knowledge of the origin of the humanity. Research and get your own proves.
1) Copy all your code to an editor (Ex: Notepad)
2) Go File > Delete Preject (on GAS window of the working project)
3) Return to the related Spreadsheet or Form and open Script Editor again. (A new project will be opened)
4) Paste your code in the new project
5) Run the function that access the external spreadsheet and GAS will ask again for permission to access.
If it happened on triggers, just remove the trigger and insert again that GAS will ask for permission.
Save!
Peace for all!
Racional Culture, the knowledge of the origin of the humanity. Research and get your own proves.
az...@mincko.com <az...@mincko.com> #50
Hello,
Is there any update on this issue? Inside my onEdit function, I need to call other file by using openById. It runs perfectly in run or debug mode. However if I edit something on the spreadsheet, I'm getting You do not have permission to call openById. This was working perfectly previously.
Is this issue going to be resolved? I need an answer please. Otherwise what is the best solution to read other spreadsheet during onedit? Appreciate any feedback.
Is there any update on this issue? Inside my onEdit function, I need to call other file by using openById. It runs perfectly in run or debug mode. However if I edit something on the spreadsheet, I'm getting You do not have permission to call openById. This was working perfectly previously.
Is this issue going to be resolved? I need an answer please. Otherwise what is the best solution to read other spreadsheet during onedit? Appreciate any feedback.
wi...@oneillwineops.com <wi...@oneillwineops.com> #51
Any work around???
vi...@gmail.com <vi...@gmail.com> #52
Hi, i'm using var document = SpreadsheetApp.openById(getDocumentId()); upon a menu action and getting You do not have access to perform that action. Please ask the owner of this item to grant access to you
Could you share how did you work around it?
Thanks
Could you share how did you work around it?
Thanks
ca...@tecnoalsa.com <ca...@tecnoalsa.com> #53
Answer #49 worked for me.
But, still there is a question to google team:
should this mess be done?
What was the reason behind?
Anyway, thanks for this not so clean solution.
ar...@gmail.com <ar...@gmail.com> #54
Last week, I made sure that openByUrl was working before I go deep in making project and it did. I dont know what the hell is going on! Plus, as commented by others, how can this be a security issue for depreciating this important feature?
me...@gmail.com <me...@gmail.com> #55
Comment has been deleted.
[Deleted User] <[Deleted User]> #56
<purged>
fu...@gmail.com <fu...@gmail.com> #57
ARREGLEN ESTO GOOGLEEEEEEEEEEEEEEEEE
ji...@expertosis.com <ji...@expertosis.com> #58
Cuál es la solución a esto?
jp...@google.com <jp...@google.com> #59
Many of the questions here imply an editor add-on using onEdit
or onOpen
. See the documentation at AuthMode.LIMITED
. This is an important security consideration to ensure users must authorize the sensitive scopes. A similar comment was shared in
Description
Sample code snippet:
var session_report_sheet = SpreadsheetApp.openByUrl('
var session_reports = response_sheet.getActiveSheet();
What steps will reproduce the problem?
1. Open GAS script - project key MaLH4_s-kpNJxWR2BkzaMS7F4cojZcNfF
2. Run the sendAlerts() function, which tries to call SpreadsheetApp.openByUrl() function - you will get the above error
What is the project key (found under "File > Project properties")? The
project key does not give the Apps Script team access to your source
code or data. We use it to look up debug information about your script.
MaLH4_s-kpNJxWR2BkzaMS7F4cojZcNfF
Please provide any additional information below.
To subsequent readers: If you are also experiencing this issue, please
click the star next to the issue number. We prioritize issues with the
most stars.