将Google App脚本部署为表格加载项后,菜单项未出现 [英] Menu Items not appearing after deploying google App Script as Sheets Add-On
问题描述
我已经开发了脚本并部署了&将其发布为加载项,这是内部应用程序.我可以在表格中看到加载项,但是只有主菜单可见.在onOpen(e)中创建的菜单项不可见.
I have developed a script and deployed & published it as Add-On, this is internal app. I am able to see Add-On in Sheets, but only main menu is visible. Menu items created in onOpen(e) are not visible.
这些菜单在我执行测试时可见,但仅在安装到另一个用户中时才起作用.
These menu's are visible when I performed testing but not working only while installing in another user.
我想我在部署中遗漏了一些东西.有人可以帮我吗?
I guess I am missing something in deployment. Can someone help me with the same?
步骤1:我单击发布"->作为附件部署"->收到以下消息:您必须配置G Suite Marketplace SDK才能发布附件."
Step1: I clicked on Publish-->Deploy as add-on--> got message as "You must configure the G Suite Marketplace SDK to publish an add-on.".
第二步:我去了GCP,从APIs启用了G Suite Marketplace SDK.在配置和发布中提供了所有详细信息,然后单击发布".
Step2: I went to GCP, enabled G Suite Marketplace SDK from APIs. Provided all details in configuration and Publish and clicked on Publish.
Step3:现在,该插件在GSuite市场中可见并且可以安装.但是只出现主菜单,里面的子菜单没有出现.
Step3: Now, the Add-On is visible in GSuite market and able to install it. But only Main menu is appearing, sub menu's inside it are not appearing.
function onInstall(e) {
onOpen(e);
}
function onOpen(e) {
var menu = SpreadsheetApp.getUi().createAddonMenu(); // Or DocumentApp.
if (e && e.authMode == ScriptApp.AuthMode.NONE) {
// Add a normal menu item (works in all authorization modes).
menu.addItem('Submit to Level1', 'P_Level1');
menu.addSeparator();
menu.addItem('Submit to Level2', 'P_Level2');
} else {
// Add a menu item based on properties (doesn't work in AuthMode.NONE).
var properties = PropertiesService.getDocumentProperties();
var workflowStarted = properties.getProperty('workflowStarted');
if (workflowStarted) {
menu.addItem('Submit to Level1', 'P_Level1');
menu.addSeparator();
menu.addItem('Submit to Level2', 'P_Level2');
} else {
menu.addItem('Submit to Level1', 'P_Level1');
menu.addSeparator();
menu.addItem('Submit to Level2', 'P_Level2');
}
menu.addToUi();
}
}
关于, 克里希纳(Sai Krishna).
Regards, Sai Krishna.
推荐答案
这很好.我提到的步骤已更正.
This is working fine. The Steps I have mentioned are corrected.
它不起作用,因为我在下面的输入框中输入了脚本ID.我将其更改为项目密钥(已弃用)",并且工作正常.
It did not work as I have given Script ID in below Input box. I changed it to "Project key (Deprecated)" and it worked fine.
谢谢大家的投入.
这篇关于将Google App脚本部署为表格加载项后,菜单项未出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!