1

i have the below script which is helping me to embed google form into a google sheet while i have 2 forms in the same sheet and when i put the script both am getting only one selection which is a select button created near HELP called SELECT

i was unable to post the script

while the output only BBB on the selection option,

the sheet is here :

https://docs.google.com/spreadsheets/d/17O84HASI6q17sDH00tKmh_KrHmipUnxGcxafQrarG_c/edit#gid=1543122132

FormAAA: https://docs.google.com/forms/d/1UpG6E08dH3L9YCqCoDpOw2Y4K--7utx1vhpORishxTU/edit FormBBB: https://docs.google.com/forms/d/1_lDDKwaS0EizUdMSoP4FtgVqUe5PImpPBlH8JLItoW0/edit

Looking forwards to your kind help.

Thanks, Adabsiz

1 Answer 1

2

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");
}
Sign up to request clarification or add additional context in comments.

4 Comments

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
@Adabsiz Thank you for replying. About is there possibility to keep both open with its own sheet., I couldn't notice this from your question. This is due to my poor English skill. I deeply apologize for this. Unfortunately, in the current stage, 2 sidebars cannot be opened simultaneously. So I proposed 2 workarounds in my answer. Could you please confirm it? If that was not the direction you expect, I apologize again.
i 'm so happy to see how you try to help, unfortunately when i switched between the tabs i still see BBB sheet which i was hopping to be like AAA you could have a look at the sheet as i applied the script, what am looking for is every sheet with its own form if possible even if i will show without selection i don't mind it. Thanks again for the help
appreciate your kind response, i did closed and recommend your earlier answer as well. thanks again for the support and advice

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.