简体   繁体   中英

Server Side and Client Side communications Functions with values at Google Apps Script

Here's the problem...

I saw this post on the internet, and this is very useful for my day job. so I adapted the code to do what I need.

The problem: in Client Side, I need to show form and the Server Side made the rest of the code, just receiving the values from the client. note: The client-side can't change code from the Script Editor tool.

See the screenshots below to fully understand.

Server Side - Code

服务器端代码

Server Side - Form (HTML View) 在此处输入图像描述

Server Side - Form (Script Code in HTML to read Values) - similar to the post from Yagisanatode在此处输入图像描述

Server Side - Logger values在此处输入图像描述

until here, everything works perfectly, the problem comes when I try to import it to the client Side.

Client-Side - Library Import

在此处输入图像描述

Client Side - Code

在此处输入图像描述

Client Side - Form (HTML View) 在此处输入图像描述

all seems to be working. but when the client hit de submit button. NOTHING WORKS. the function addRegistro(values) on the client-side don't run. also don't run on the server-side!

so, I appreciate the help from the community, to understand why this happens. what I doing wrong?

Change button type from submit to button. it works.

I bet your problem is in the "novoRegistro" function. The function in the library is probably not accessing the current spreadsheet. Google documentation about spreadsheetapp.getUI says "A script can only interact with the UI for the current instance of an open spreadsheet, and only if the script is bound to the spreadsheet.". Try to put the function "novoRegistro" in your application.gs code instead of the library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM