Technical > GScript > Index of Examples
The master reference for Google Script and Google Objects:
DIY Composite gScript Reference
- Gsheet/GDrive/PDF/Gmail - Email a single tab/sheet from a Google Sheet to a mail recipient as an attached pdf -- Make copy of a single worksheet as pdf, save to drive (optional), attach to email and send, delete from drive (optional) - 10_Point of Sale (retail) The same thing can also be done a harder way: Create new workbook, make copy of a single worksheet in existing workbook in new work book (gets formats and cell vals as equations), make copy of existing worksheet as values only in existing workbook, paste those values over the templated page in the new workbook 10_Point of Sale (retail)
- Gsheet/GDoc/Gmail - Mail merge gsheet data into gDoc, then copy and paste the GDoc body into body of an email as html and send (or save as draft) The hardest part about this is getting the html into the body of the email as the html version of the GDoc uses page level css in the header section, and gmail requires inline CSS. We are currently relying on a CSS conversion tool available via a MailChimp API (thank you!), but we are hoping to build our own conversion system with a head start from other online resources. 10_Reservations (vacation rental software)
Extensions / Addons
Below is a list of addons/extensions we've used. Many of these acted as the inspiration to build out more robust, custom solutions.
- Autocrat - Autocrat is a Gsheet mail merge addon that enables you to merge gsheet data with a gdoc template and save as one or multiple gdocs (or pdfs?). It has gone thru numerous iterations. I found a bug with formatting related to tables. An extra space is added after the initial page of the template, likely a google issue. Most people have good experience with this but it is a little complex (to be expected). This was initially used conceptually to inspire our various versions of mail merge. View in chrome store
- Convert Google Docs to Gmail Drafts -- This is an app that puts a button in gDocs that enables a user to cut and paste their data from GDocs to the body of a draft email with the click of a button while retaining all formatting as html (which is the hard part). This was initially used conceptually to inspire our more robust application of this as it relates to combining mail merge with in body emails for contract presentation and ratification. View in Chrome Store
- Gorgias Templates: Email Templates for Gmail - This extension expands on the "canned responses" lab that has been in gmail for some time. We have not seen a need to build our own version of this yet. View in Chrome Store
- Mapping Sheets - This enables the creation and publishing of maps using Gsheets data. Very powerful. Several settings. A little confusing to get giong, but once going, easy to use. We have not built out our own version of this yet. We are not using this in any production systems at this time. View in Chrome Store
bcLIB1
We don't typically use or distribute Libraries for most of our software, but we do use them some in our own in house systems.
This copy is set to read only. You can use this as a reference and cut and paste those you'd like to use into your own gsheets script modules.
The BCLIB1 library can be duplicated by you. We don't share that in a functional manner for various reasons., but you can copy the code and paste into your own master file or into your own gsheets script files (with some minor file ref name changes).
LINK HERE WHEN time comes...
This copy is set to read only. You can use this as a reference and cut and paste those you'd like to use into your own gsheets script modules.
The BCLIB1 library can be duplicated by you. We don't share that in a functional manner for various reasons., but you can copy the code and paste into your own master file or into your own gsheets script files (with some minor file ref name changes).
LINK HERE WHEN time comes...
Background
Google Script is javascript with access to a wide range of powerful objects that are Google specific.
- Imagine a scripting module built into a Google Spreadsheet. Imagine writing a script in that module that accesses a spreadsheet tab, makes a pdf copy of it, stores the pdf copy in Google Drive under a specific folder, and then attaches a copy of the new pdf file to an email and sends the email to the recipient, all in a single click.
- In this example, Gsheets, GDrive and Gmail can all be accessed via Gscript that is contained in a "project" that is associated with a specific Google Spreadsheet that contains the source material.
- If we wanted to, we could have pulled canned email body content from a Google Doc in this process too... we could have also done this for a serious of tabs or data, and we could have saved as ZIP files, etc etc etc.
There are generally two places to create/host Google Scripts.
- Intrinsic Script Projects -- There is a scripting module in Google Sheets and Google Docs files (Tools > Script Editor). Think of this intrinsic project as places to write "macros" in google script that can do things both within the existing files and outside of them. These intrinsic script projects can NOT be seen nor identified in Google Drive. They are an inherent part of the source file. To confuse things a little, you can have multiple intrinsic Project Files associated with a given Google Sheet or Google Doc, but you can only have one associated at any given time, so think of this as a way to save and reference prior versions of scripting projects.
- Stand Alone Script Projects -- The same scripting interface can be created as a single file in google drive without any specific affiliations to a given Google Sheet/Google Doc If you want to write libraries, you do it in these stand alone script modules and then reference them from intrinsic script projects.