Google App Script: Run script from within another script? - google-apps-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.

Related

How to generate an HTML view in App Script from a Google Sheet

I have a client that uses Google forms to take orders and wants to be able to turn the resulting Sheet into a document of Packing Slips. Being a python person I am currently taking her .tsv and making nice HTML printable docs but want to be able to make a plug-in for her so that on any Sheet of this type she can click "Make Packing Slips" and it either opens a new tab with generated HTML (I'm ok using googles templating) or maybe even convert the HTML into a PDF and save it to her drive? Either way I'd rather design the document all in HTML and CSS rather than trying to make a google doc if at all possible. Is the feasible? Any starting points? Thanks!
You need to learn about Google App Script => https://developers.google.com/apps-script/overview
Then these Links should suffice
HTML Service: Create and Serve HTML
Google Container-bound Scripts for Google App Script (Can not post link for this due to low reputation)

Display custom message after submitting a Google Form

I have a Google Form that allows user to enter their information. After they submit the form, the data is inserted to a Google spreadsheet as a new row.
However I want to show a dynamic message right after the form is submitted, overriding the original "thank you" message. The new message would display the information they just filled in, with an number assigned to him.
For example, Mary filled in her data and submit the form. Since Mary is the 5th person to submit this form, the message shows her number as 5.
Is there any way to achieve this? I have been studying Google App Script and HTML service but I am not sure if this is the correct way.
Please note that we have already using email to send out this message for several years however user strongly suggest that showing their ID right after form submission would make lots of things much easier.
Thank you very much!
Update
I have been working on it and now I am able to make a web page that inserts a new row to a spreadsheet. But another question: How to publish the web page? When I open the "/dev" link it works fine; However when I open the "/exec" link it says cannot find "Index.html" and I am sure there is a file called Index.html.
There is no way to add a custom confirmation message for the current user of the currently open Form. You can run code to change the confirmation message when the Form is submitted, but changing the confirmation message when the Form is submitted won't take affect until the NEXT Form is opened, and that's too late. So the next person to open the Form would get the confirmation message of the previous user.
You would need to convert everything to a stand alone HTML App for something like that.
Google just released a new version of Google Forms. In the settings you can change the confirmation page message for respondents. You can save a link to a web page in the custom message. So if you can create a web page with the data you want displayed, you should be able to save the link in the custom message.
In order to achieve the above-mentioned goal, you need to get the Google form on your web page. No, I am not talking about embedding the form to your web page but to create a stand alone HTML page. The reason behind doing so is since Google is a third party website, editing any code in Google forms is not possible and there is no other way (at least I could not figure out Yet) to place custom thank you page URL for the Google Form. You can even remove certain codes in your HTML page to make sure it doesn't look like or says Google form. Basically, to have custom URL you need to replace
Code to be replaced for custom Thank you url in Google form
In case you are not a techie, Playing with codes might break the code.This step by step blog for customising Google form might help you.

How to embed Google Compose Mail window in to Google Sheet Form?

I won't bore everyone reading this post with the entire background story of why I need to do this. However, I am looking to load the Google Compose Mail page in the HTML form loaded inside a Google Sheet I have created.
I know the link for the Compose email is https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=TO&su=SUBJECT&body=BODY
But I don't know if it is possible to have this link loaded as a view in the HTML service Form.
Does anyone know if this is possible and if so, how to do it?
I could always have a button to load the link in a separate tab... but I would like to have this all kept on screen to be more "professional" looking.
I was looking for an option to add an iframe or free code, but option exists. I recommend inserting a form if you are looking for a way to get data from users.
Its under "Insert", then "Form..."
Good Luck

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? :