3

Reference :

Single Google Form for multiple Sheets



Re-claim :

  1. I have a little bit hard to made my writing some good or as well to be understanding (less english).
  2. I have a little insight about a Google Apps Script (GAS).
  3. I have change "MyURLDoc" and "MyIdDoc" bellow as cosinderring of mine.




Question :

How do I make a Google Form be inside of a Pop up what I've made in Google Spreadsheet ?





Attempt 1 :

function goToURL() {
  FormApp.openByUrl(//*** MyURLDoc! ***//);
}





Attempt 2 :     Following as the reference has worte there!

function goToForm() {
var form = FormApp.openById(//*** MyIdDoc! ***//),
    formUrl = form.getPublishedUrl(),
    response = UrlFetchApp.fetch(formUrl),
    formHtml = response.getContentText(),
    htmlApp = HtmlService
  .createHtmlOutput(formHtml)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME)
  .setTitle('Ta Daaa!')
  .setWidth(500) 
  .setHeight(450);  SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);
}





Problem :

It says always like this:     " No item with the given ID could be found or You do not have permission "

Deby Ferdian
  • 69
  • 3
  • 9
  • Possible duplicate, check this one https://stackoverflow.com/questions/17152120/single-google-form-for-multiple-sheets – mTorres Jul 23 '17 at 08:48
  • Ofcourse it is. @mTorres! Because the link what I gave as a (**Reference**) before you given an above in attached at your comment at there is an indeed REALLY SAME QUESTION BUT IT'S NOT SAME A PROBLEM. Because in my case I've found new problem plus meanwhile I can't post back my comment at there. It's all because my reputation still are low so I need to repost back here at my new thread to Re-claim if I've found a new problem. – Deby Ferdian Jul 23 '17 at 08:58
  • Sorry, my bad for reading too quick, but did you got the ID while editing the form or when viewing it? This would be a small mistake, but we're humans and we all do these, and also the view form does not have permission issues but editing does. – mTorres Jul 23 '17 at 09:02
  • Well. I don't know But I have change my ID with the view one but the resort all same nothing changes all really pretty same the warning is always cameout just like that. – Deby Ferdian Jul 23 '17 at 09:11
  • I am pretty sure you are entering the wrong form Id – Ritesh Nair Jul 23 '17 at 13:32
  • RELEASE: If I made a change and use the script "openById" the warning becomes looks like this: "_**Sorry, there was a server error Wait a minute and try again.**_" – Deby Ferdian Jul 23 '17 at 18:47

1 Answers1

5

Creating a Sidebar with a Google Form

I just went to an old form I have and got the embed code. I loaded into a sidebar that I had on another project and pasted the embed code which is an iframe and it loaded perfectly except for the size and I ran the form and sure enough it loaded data into the spreadsheet that contains it.

I thought I'd go ahead and add a complete example. This is a simple example which creates a form for inputting time stamped text into a spreadsheet. It's done two ways. The first technique uses standard html, javascript, JQuery and Google Script. The second technique is accomplished by just creating a form and embedding it into a simple html page. Both versions fit into the side bar and both are linked to spreadsheet pages where the text is loaded and timestamped.

Code.gs:

function onOpen()
{
  SpreadsheetApp.getUi().createMenu('My Tools')
    .addItem('createTextEntryForm', 'createTextEntryForm')
    .addToUi();

  loadSideBar();
  SpreadsheetApp.getUi().createMenu('My Menu').addItem('loadSidebar', 'loadSideBar').addToUi();  
}

//This loads the text into the spreadsheet for the html version of the form.
function dispText(txt)
{
  var ss=SpreadsheetApp.getActiveSpreadsheet();
  var sht=ss.getSheetByName('Notes');
  var ts=Utilities.formatDate(new Date(), 'GMT-6', "M/dd/yyyy HH:mm:ss");
  var row=[];
  row.push(ts);
  row.push(txt);
  sht.appendRow(row);
  return true;
}

function loadSideBar()
{
  var userInterface=HtmlService.createHtmlOutputFromFile('formBar');//sidebar for html and formBar for form
  SpreadsheetApp.getUi().showSidebar(userInterface);
}


//This is the form
function createTextEntryForm()
{
   var ss=SpreadsheetApp.getActiveSpreadsheet();
   var form=FormApp.create('Form On A Sidebar');
   form.setDescription('Enter Your Message and Push Submit when complete.')
       .setConfirmationMessage('Message Saved and TimeStamped.')
       .setAllowResponseEdits(true)
       .setAcceptingResponses(false)
       .setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
   var containerLink=form.addParagraphTextItem();
   containerLink.setTitle('Enter your comment now.')
       .isRequired();
}

sidebar.html which is the html version of the form:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>
    $(function() {
        $('#txt1').val('');
      });
    function sendText()
    {
      var txt=$('#txt1').val();
      google.script.run
        .withSuccessHandler(clearText)
        .dispText(txt);
    }
    function clearText()
    {
      $('#txt1').val('');
    }
    console.log("My code");
  </script>
  </head>
  <body>
  <textarea id="txt1" rows="12" cols="35"></textarea>
<br />
  <input id="btn1" type="button" value="submit" onClick="sendText();" />
  </body>
</html>

formBar.html is where the form is embedded:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <iframe src="FormURL?embedded=true#start=embed" width="300" height="550" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
  </body>
</html>

This is what the spreadsheet and sidebars look like:

enter image description here

enter image description here

Cooper
  • 59,616
  • 6
  • 23
  • 54
  • Yeah, finnaly I get the light from you @Cooper. Thanks! Yeah, well.. You right I didn't expected this since the beginning and won't tried yet this before then after I tried this and then TTAAADDAAA !!! it's work and I don't know how but it totally wonderful great work . . . ^_^ – Deby Ferdian Jul 24 '17 at 17:41
  • @DebyFerdian I added a complete example. This simple form is created in Google Apps Script. – Cooper Jul 24 '17 at 19:43
  • Hi, @Cooper? I have litle bit a question which where this has been availabe in another thread. How do we appear or load the multy popup on the same window as together but NOTE: not with the combine of the other applications like; "sidebar". – Deby Ferdian Jul 25 '17 at 06:26