When I saw your sample Spreadsheet and your script, I confirmed that 2 functions of onOpen() and showSidebar() are duplicated in AAA.gs and BBB.gs. I think that this might be the reason of your issue. When you want to put AAA and BBB to the custom menu, how about the following modification?
From:
AAA.gs:
function onOpen() {
SpreadsheetApp.getUi().createMenu("SELECT NAME").addItem("BBB", "showSidebar").addToUi();
}
function showSidebar() {
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("SidebarAAA.html").setTitle("DATA ENTRY"));
}
BBB.gs:
function onOpen() {
SpreadsheetApp.getUi().createMenu("SELECT NAME").addItem("BBB", "showSidebar").addToUi();
}
function showSidebar() {
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("SidebarBBB.html").setTitle("BBB"));
}
To:
AAA.gs:
function onOpen() {
SpreadsheetApp.getUi().createMenu("SELECT NAME")
.addItem("AAA", "showSidebar1")
.addItem("BBB", "showSidebar2")
.addToUi();
}
function showSidebar1() {
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("SidebarAAA.html").setTitle("DATA ENTRY"));
}
function showSidebar2() {
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("SidebarBBB.html").setTitle("BBB"));
}
BBB.gs:
In this case, onOpen() and showSidebar() in BBB.gs are not used.
// function onOpen() {
// SpreadsheetApp.getUi().createMenu("SELECT NAME").addItem("BBB", "showSidebar").addToUi();
// }
// function showSidebar() {
// SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile("SidebarBBB.html").setTitle("BBB"));
// }
Reference:
Added:
About your following additional question,
Hi, appreciate your kind advice and follow up, i did add the suggested script while i choose BBB with its linked sheet as well as AAA with it's linked sheet; unfortunately only one form kept open either AAA or BBB, is there possibility to keep both open with its own sheet. looking forwards to your kind advice. Thanks
Unfortunately, in the current stage, 2 sidebars cannot be opened simultaneously. So in this case, how about the following patterns?
Pattern 1:
In this pattern, SidebarAAA.html is modified as follows. By this, when "AAA" is run, 2 Google forms are opened in a sidebar.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSfixYMtU8QYFC4tUI5XhZDzPsSXcyMNcmnodhG11r6vP6opew/viewform?embedded=true" width="100%" height="900" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSfZGw4fdkxoec6df-q0VEmbKcBf4Exqg5E-BbEDGvIHzXOiKA/viewform?embedded=true" width="100%" height="900" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
</body>
</html>
Pattern 2:
In this pattern, SidebarAAA.html and SidebarBBB.html are opened in a sidebar and a dialog, respectively. In this case, please modify showSidebar2() as follows.
function showSidebar2() {
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutputFromFile("SidebarBBB.html"), "BBB");
}