Adding image to the SectionHeaderItem in Google Forms Apps script - google-apps-script

I've been using Google Apps Scripts to generate Google Forms and sent be email.
However, i've been trying to add a logo to the header section however there is no function or a possible way that I can find online of adding it.
I can add images using ImageItem(), however, this does not add to the header section and stays as a single item at the start of the form.
Is there anyway of adding images to the header section using google apps script or thats only possible using the customizable UI made for designing google forms?

Assuming that for "header section" you mean the form header, the Forms Service doesn't include any class for the form header, so the only way to customize it is by using the Google Forms editor. By the other hand SectionHeaderItem, doesn't allow to insert images, only a title and a description.
Reference
https://developers.google.com/apps-script/reference/forms

Related

How do I reference a support file in Google Apps project

Is it possible to use a support file from within the apps script project as a source for iframe in another HTML.
I need to do this as a part of a Web App project in Google Apps Script.
Specifically I need it to work as a menu system which is the same across multiple pages, so that I don't have to repeat the same HTML code over and over again.
Better explained in a picture
Left side menu(buttons) stays the same across pages
There are several ways to accomplish what you are looking (" I don't have to repeat the same HTML code over and over again") but using iframe is not the best way when working with Google Apps Script web applications.
First you have to decide if you want to handle your web application as a multipage or as simple page.
In any case you might find helpful to use templated HTML / scriptlets to pass the code from Google Apps Script .html files to your main html code. If you find yourself scripts hard to start with, then you might use other methods of the HTML Service
Resources
https://developers.google.com/apps-script/guides/html/
https://developers.google.com/apps-script/guides/html/templates
https://developers.google.com/apps-script/reference/html
Related
Use project Javascript and CSS files in a Google Apps Script web app?
Recent related question (no answers at this time, but with comments)
HTML Service: Templated HTML as sidebar
Is it possible to create navigation bar on Google Apps Script?
how to connect a navigation bar (<nav>) with HTML files in google appscript?

Updating html of a Google Site's page with multiple blocks using Google Apps Script

I've created a page using "Web Page" template on my Google Sites, and I want to update the page using Google Apps Script. My code looks like this:
var template = HtmlService.createTemplateFromFile('mytemplate'); // meaning 'mytemplate.html'
var content = template.evaluate().getContent();
var site = SitesApp.getSiteByUrl('https://sites.google.com/site/example/');
var page = site.getChildByName('home');
page.setHtmlContent(content);
This works pretty well if the page's layout is "One column (simple)". Now my question is, if I choose one of the other layouts, how can I update each individual blocks using setHtmlContent()? Actually, I tried using "Two column (simple)" layout which has 2 blocks. setHtmlContent() changed the left column's html code and cleared the other column.
EDIT: What I actually wanted to do is to create a page with a gadget and update the page using Google Apps Script. According to this issue tracker https://code.google.com/p/google-apps-script-issues/issues/detail?id=572, it looks like we may encounter some problems when updating such page with setHtmlContent(). So I came up with an idea to create a multiple-column page, place a gadget in a column, and only update the HTML code of the other column with the Script to avoid such issue.
You can also create a Stand Alone Web App with Apps Script, then put an Apps Script Gadget into a Sites page. You can have multiple Apps Script Gadgets. I don't know what is triggering the change of the HTML. For all practical purposes, a Stand Alone Apps Script HTML Service App, is basically the same thing as a web site. You don't have a nice, understandable URL, but that won't show up in the Apps Script Gadget. Google will display a message: "This content was not created by Google"
I don't think you'll be able to inject HTML into multiple columns. You could create HTML that has multiple columns in it, and then add that HTML to the one column. So, you would be creating your own columns in HTML.

How to Add Hyperlinks to Google Forms user Google Apps Script

I'm trying to use Google Apps Script to add hyperlinked rows to a GridItem, ideally that act as tooltips. Am I trying to do more than is possible with Google Apps Script?
Here's the situation: I have a GridItem type question that has lengthy row descriptions. To clean up the interface, I'd like to present a short summary of the description that, when clicked/hovered, reveals the full text. To do this, I'd need to turn the short summary into a hyperlink. However, I haven't seen any way to insert hyperlinks in GridItem rows. I thought that Google Apps Script may allow me to do this.
So far, I've tried entering a string followed by .setLinkUrl(), using createAnchor('text', url), using markdown, and actually inserting, as text, <a href='http://google.com'>Google</a>' for the row. Nothing has worked so far.
Is this possible at all?
EDIT:
I apologize - I didn't research this question well enough before posting. Turns out Google Forms auto-detects URLs and posts them as links in the live form. I still have an issue with this, though - I'd rather have some specified text displayed to the user instead of the URL (some of my URLs are lengthy). Anyone know how to do this?
You can design the main elements of the Google form the normal way. Then preview the live form, copy the generated html file, hosted in your website.
Then you can replace the <a>...</a> tag that is generated by Google Form by one you need e.g. <a href='http://google.com'>Google</a>
keep sure you don't disturb any styles or code that may be needed by the Google form to work.
This solution need to have your own web hosting.
You will need to point your users to your website not the live form preview.

Google Apps Script add code to copy of a document

I created a document bound script in Google Docs that allows me to select a part of some text in a document. Then when I click my menu button it will make a copied document with only the selected text in it. The script then shares the copied document and emails the person that it was shared with them.
I would like it to be possible that the user of the shared document is able to read that document, and send a message back via a form on what he thought about it. So he would also go to a customized menu button, click on it, a form would pop up and he would email me back with the text.
I know how to do this in Google Apps Script manually. I can go to the copied document and just add that script. But how do I automize this? I looked at the Google Apps Script references but could not find anything.
It is not possible to embed a script in a document using a script.
You could use a template that has a script , make a copy of it and add your content to that copy instead of creating the new doc from scratch.
Depending on the document content it might be very simple ...or just a bit more complex since you will have to add each element in turn. There are a few examples of this process here: How to copy a template and insert content from another document? :

Google App Script: Run script from within another script?

I am working on a payroll web app for my company. I was wondering if there is anyway to run a script from within another script. Such as having a hyperlink or something similar that the user could go and see a different UI and everything. If this is not possible, does anyone knows how to submit a copy of a html form to an email? I been trying to do this but GAS removes the styles and the JavaScript code that fills the form before sending it. I just need at least an image of the form so the manager could print it out and sign it.
Thanks
Yes, you can link from one script to another using regular anchors.
It's not Apps Script stripping your emailed form of this stuff. Email clients, including Gmail, intentionally don't support complex HTML. If you want an image, try creating a Google Doc with the DocumentsApp, converting it to pdf with document.getAs("application/pdf") and then emailing that.