简体   繁体   English

通过应用脚本调用应用脚本函数时出现 UI 错误 API

[英]UI Error while calling app script functions through app script API

I have written functions in the app script bound to a google sheet that validates sheet data and shows a pop up in the sheet when there is an error.我在绑定到谷歌工作表的应用程序脚本中编写了函数,该工作表验证工作表数据并在出现错误时在工作表中显示一个弹出窗口。

Now, I am calling same functions form API calls in a Node js application to return a validation response without interacting google sheet.现在,我在 Node js 应用程序中调用 API 调用相同的函数来返回验证响应,而无需交互谷歌表。

API calls are successful, function gets called but unable to initialize UI. API 调用成功,function 被调用但无法初始化 UI。 I just don't want to write duplicate functions for same purpose but without accessing UI.我只是不想为相同的目的编写重复的函数,但又不想访问 UI。

I get an error that says Script error message: Exception: Cannot call SpreadsheetApp.getUi() from this context.我收到一条错误消息,显示脚本错误消息:异常:无法从此上下文中调用 SpreadsheetApp.getUi()。

How do I solve this issue by retaining the UI calling functionality of the app script functions and also getting work done through API?如何通过保留应用脚本函数的 UI 调用功能并通过 API 完成工作来解决此问题?

You can put the call in a try catch block.您可以将调用放在 try catch 块中。

try {
  SpreadsheetApp.getUi();
} catch (f) {
  // do nothing here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 React 应用调用 REST API 时出错 - Error while consuming calling REST API with React app 使用谷歌应用脚本调用 UPS API 时获取截断 JSON 响应 - Getting Truncated JSON response when calling UPS API using google app script 如何以脚本而非应用程序的方式访问Instagram API? - How to access the Instagram API as a script not an app? 通过应用程序脚本api将文档导出为PDF - Export a document as a PDF via app script api 我为网站制作的应用程序的此api脚本无法正常工作 - this api script for a app for a site i made is not working bash 向 api 发送数据时出现脚本错误 - bash script error while sending data to api 控制台应用程序中的最大并行任务,以及调用 API 时如何处理“将内容复制到流时出错” - Max parallel tasks in Console App, and how to handle "Error while copying content to stream" when calling API 您正在公开分享您的App Secret。 不要在浏览器中公开App Secret:从Angular调用getStream API时出错 - You are publicly sharing your App Secret. Do not expose the App Secret in browsers: error while calling getStream API from Angular 通过AJAX调用BigCommerce API时出现401错误 - Getting 401 error while calling BigCommerce API through AJAX 编写调用 Python 脚本的 API - Writing API for Calling Python Script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM