Can I use scripts alongside or in reference to an Add-on's functions in Google Sheet?

不打扰是莪最后的温柔 提交于 2021-02-15 07:54:58

问题


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().

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 - 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?

(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 - 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?

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 - 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.

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.)

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...)



来源:https://stackoverflow.com/questions/26287664/can-i-use-scripts-alongside-or-in-reference-to-an-add-ons-functions-in-google-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!