我可以在Google表格中与附加功能一起使用或引用附加脚本吗? [英] Can I use scripts alongside or in reference to an Add-on's functions in Google Sheet?

查看:24
本文介绍了我可以在Google表格中与附加功能一起使用或引用附加脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Google表格,其中使用了 Autocrat插件.我创建了一个脚本,该脚本执行了一些我想由onFormSubmit()触发的操作.

I've created a Google Sheet in which I am using the Autocrat Add-on. I've created a script that takes further actions that I would like to triggered by onFormSubmit().

我注意到的是,如果我在脚本编辑器"中运行脚本,它可以很好地执行并在我希望其成功执行的电子表格上执行操作.但是,当我在表单上提交新条目时,它不会运行脚本-无论是否将Autocrat配置为对onFormSubmit()采取措施.(此功能是最近几天由附加组件的作者添加回去的.)

What I notice is that if I run the script in the Script Editor, it executes fine and takes the actions on the spreadsheet that I want it to successfully. When I submit a new entry on the form, however, it doesn't run the script - regardless of whether Autocrat is configured to take action onFormSubmit() or not. (This functionality was just added back by the add-on authors in the last couple of days).

这是一个分为两部分的问题:

This is a two-part question:

1-有什么方法可以让脚本在附件执行之后(或之前,对我而言无关紧要)执行?

1 - is there any way to get the script executing after (or before, in my case it doesn't matter) an Add-on does its thing?

(Autocrat开发人员尚未在GitHub上发布该插件的代码,因此我只能推测其中发生了什么.)

(The Autocrat developers have not yet posted the code for the add-on on GitHub so I'm only able to speculate as to what's happening in there.)

2-我是否可以通过其他工作表中的脚本来触发加载项的功能?Autocrat具有运行合并"功能,可以通过在工作表界面中按一个按钮来访问该功能.我希望能够从其他工作表中的用户事件触发此操作.

2 - is there a way for me to trigger the add-on's functionality with a script in a different sheet? Autocrat has a "Run Merge" function which can be accessed by pressing a button in the interface of a sheet. I would like to be able to trigger this from a user event in a different sheet.

我的直觉是,这两个问题的答案都是等待开发人员发布代码",但想看看是否有更多经验的人有其他想法.任何帮助将不胜感激.

My instinct is that the answer to both these question is 'wait for the developers to release their code' but wanted to see if anyone with more experience has other thoughts. Any help would be most appreciated.

推荐答案

1-有什么方法可以让脚本在附件执行之后(或之前,对我而言无关紧要)执行?

1 - is there any way to get the script executing after (or before, in my case it doesn't matter) an Add-on does its thing?

您无法协调加载项和您自己的脚本的操作.加载项可以提供自定义功能(带有 @customfunction jsdoc标记),这些功能可用于启用了该加载项的工作表,但否则该加载项的名称空间将被锁定.您自己连接的脚本看不到任何符号.

You aren't able to coordinate actions of the add-on and your own script. Add-ons can provide custom functions (with @customfunction jsdoc tags) that are available to sheets that have enabled the add-on, but the namespace of the add-on is otherwise locked down. None of its symbols are visible to your own attached scripts.

2-我是否可以通过其他工作表中的脚本来触发加载项的功能?Autocrat具有运行合并"功能,可以通过在工作表界面中按一个按钮来访问该功能.我希望能够从其他工作表中的用户事件触发此操作.

2 - is there a way for me to trigger the add-on's functionality with a script in a different sheet? Autocrat has a "Run Merge" function which can be accessed by pressing a button in the interface of a sheet. I would like to be able to trigger this from a user event in a different sheet.

除了新的可安装触发器外,没有针对附加组件中的自主或远程控制"功能.(例如,如果允许,则附加组件可以为您的文档运行Web服务,从而可以响应远程控制操作.)

Aside from the new installable triggers, there are no provisions for autonomous or "remote control" capabilities in add-ons. (If it was allowed, for example, an add-on could run a web service for your document, that could respond to remote-control actions.)

对于在工作表上使用单独的脚本按下按钮",抱歉.从安全的角度来看,没有API可以在该级别上操作UI.

As far as having a separate script "press a button" that's on a sheet, sorry. There's no API to manipulate the UI at that level, which makes sense from a security standpoint.

现在,尽管如此,您的提交触发器应该运行.该名称不是魔术,您需要确保已安装它.(资源>当前项目的触发器...)

Now, with all that said, your submit trigger should run. The name isn't magic, you need to make sure it is installed. (Resources > Current project's triggers...)

这篇关于我可以在Google表格中与附加功能一起使用或引用附加脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆