Google Apps Script: "Display Form in Sidebar" -
i not sure if trying possible.
i trying set google form sidebar of google doc.
right have apps script document plugin opens sidebar fine, , able open form using var form = formapp.openbyid('form_id');
but don't know how html object or blob form element utilize embed form in sidebar.
i can't utilize iframes disallowed.
while can display google form in sidebar in spreadsheet/document (see sample code below), there 1 important gotcha it: form not work, i.e. can't submit form. not sure why, guess due sandbox restrictions and/or caja sanitization.
i suggest code own form using html , html service (or ui service) , show in sidebar. if need form save responses spreadsheet, can rather easily. see more on info , code samples of using forms in html service , this using forms in ui service. server-side script can open spreadsheet , write form values it, if that's need do.
sample code add-on show google form in sidebar in google sheet:
note: form not work - not submit when shown in sidebar!
function showforminsidebar() { var form = formapp.openbyid('your-form-id-here'); var formcontent = urlfetchapp.fetch(form.getpublishedurl()).getcontenttext(); var ui = htmlservice.createhtmloutput(formcontent).settitle("google form in sidebar example"); spreadsheetapp.getui().showsidebar(ui); }; function onopen(e) { // add together add-on add-ons menu spreadsheetapp.getui().createaddonmenu() .additem('show form', 'showforminsidebar') .addtoui(); };
google-apps-script
No comments:
Post a Comment