G
G
Grigory Boev2021-11-28 16:21:13
Google Apps Script
Grigory Boev, 2021-11-28 16:21:13

How to work with Client-Side HTML in Google Script?

Good afternoon. Tell me how to solve
There is table1 , table2 , library1 , library2 . Library1 has code to create a modal window, for example named show (). In the window I form an object and send a callback to a function that saves the answer in tables 1) In table1, if I call as , then I get it in the log: Moreover, this is not from a function, I use my own logger and gives more information there If I call from the menu , then the function is executed no problem UPD: [in the example this construction works fine, but not in the source file]




lib.show()
Информация: False
('Показать окно', 'lib.show')


2) library2 is nested in library1 , but its functions do not participate in the window call or further work. However, I get different errors: access or "404 NOT FOUND" depending on whether I select library2 in developer mode or just deploy with a version number

3) All this works on my account, but does not work on the account of the owner of all files.

4) I decided to make copies of the files, at the first start I gave out the rights, now the window is normally shown, but when I call it from the window,
google.scrip.run.callback()
an error occurs

"ScriptError: Для выполнения этого действия необходима авторизация."

Moreover, in the callback() execution logs, UPD is not executed : [I went into the library, launched the callback manually, updated the rights, the problem is gone]

5) One more thing that I can’t understand. To return values ​​from a modal window, I call
google.scrip.run
.withSuccessHandler(google.script.host.close)
.withFailureHandler(alertError)
[callback](data);

where callback is the name of the callback function.
The function is in library1
, from where the But! window is called . If you do not make a function with the same name (any content) in table1 , then at this point an error will appear in the console that google.scrip.run.google.scrip.run is not a function.
If there is a function of the same name, then everything works, but this mock function is not called, but lib.callback() is called Tell me the

search direction, I've been fiddling with this for several days and it's not clear

UPD:
table1 ,
library1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-11-29
@oshliaer

1, 3, 4 is one problem. The user must run any function from the library in order to authorize it.
5 is the most interesting thing. When you create a Ui from a lib, you lose the user's context by entering the lib's context. When the UI calls the Client-Side API, it accesses the root context. If there is no named function there, then there will be no execution, but if the name is found, then the execution is transferred to the server side, where the required context is returned. But it is also truncated, for example, this context does not know about active Tables and Documents.
At the moment, I have not been able to get a fully functional application that would work with Ui from the library.
I consider the only "more or less" option to be the delivery of the code from the lib and its eval. What is fraught, and obviously, breaks the essence of the goal of this undertaking.
The topic excites the minds https://oshliaer.github.io/qna?mnemo=gas&target=44...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question