我有一个附加组件,它利用 addOns.common.homepageTrigger 函数来显示侧边栏 (https://developers.google.com/apps-script/add-ons/concepts/homepages)
如果用户单击快速访问面板中的附加按钮,它工作得很好,但是如果他们关闭侧边栏,然后再次单击快速访问面板中的按钮,则会出现一个占位符页面,但不会发生其他情况:
{
"timeZone": "Australia/Sydney",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}
]
},
"oauthScopes": [
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/documents.currentonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/presentations",
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.apps.readonly",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.locale",
"https://www.googleapis.com/auth/userinfo.email"
],
"urlFetchWhitelist": [
"https://cm234-wgs-1.icognition.cloud/",
"https://docs.google.com/feeds/download/documents/export/Export",
"https://docs.google.com/spreadsheets/export",
"https://docs.google.com/feeds/download/presentations/Export"
],
"addOns": {
"common": {
"name": "Ingress Records",
"logoUrl": "https://hydrakubernetes.icognition.cloud/images/ingress_icon_black_40.png",
"homepageTrigger": {
"runFunction": "showSidebar",
"enabled": true
}
},
"sheets": {},
"docs": {},
"slides": {}
}
}
function showSidebar() {
var sidebarName = "sidebar";
if (getRecordUri() !== 0) {
sidebarName = "existing_record_sidebar";
}
var ui =
HtmlService.createHtmlOutputFromFile(sidebarName).setTitle(
"Ingress Records",
);
getUi().showSidebar(ui);
}
错误
Content not available for this message
是因为脚本中的Class HtmlService,并且根据Restrictions:
Card ServiceGoogle Workspace 插件必须使用基于卡片的界面。无法使用编辑器插件支持的 HTML/CSS 界面。 Google Workspace 插件使用“基于小部件”的方法来构建用户界面。这使得该插件可以在桌面和移动平台上正常运行,而无需您为每个平台构建界面。
相反,请使用
,此示例脚本是您如何从其他 Stack Overflow 帖子创建第二个侧边栏的方法。
function showSidebar() {
return CardService.newCardBuilder()
.setHeader(CardService.newCardHeader()
.setTitle("")
.setSubtitle("All fields are mandatory, unless indicated as optional."))
.addSection(CardService.newCardSection().setHeader("Record Type")
.addWidget(CardService.newSelectionInput()
.setType(CardService.SelectionInputType.DROPDOWN)
.setTitle("")
.setFieldName("RECORD TYPE")
.addItem("Option 1", "option_1", false)
.setOnChangeAction(CardService.newAction().setFunctionName("myFunction")))
.addWidget(CardService.newTextButton()
.setText("Create record")
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setOnClickAction(CardService.newAction().setFunctionName("myFunction"))))
.build();
}
输出