Package Exports
- form-google-sheets
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (form-google-sheets) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
form-google-sheets
Uses Google Apps Scripts with Google Sheets to provide a POST endpoint for form data that is parsed into sheet fields.
https://techcoop.github.io/form-google-sheets/
Requirements
- Google Account
- Google Sheet with column headers
- node > 6.0.0 (Optional)
- yarn (or npm latest) > 0.10.0 (Optional)
Installation
Google Scripts
- Change the values below as needed
- Make sure SHEET_NAME matches your spreadsheet exactly
- Click on Publish and select "Deploy as web app"
- Select new (or save over existing version)
- In "Execute the app as" select yourself
- In "Who has access to the app" Select "Anyone, even anonymous"
- Click Update
- Copy and paste the URL and use this to post information to
- Make sure form data fields match the header fields exactly
NPM package
yarn add form-google-sheets
Usage
ES6
import { Form } from 'form-google-sheets'
const endpoint = 'https://script.google.com/macros/s/AKfycbyEBGqfIUmxrLKMp_LlAlH8C_VO9vfRvtvwgjAS9lEi8Vu8xho/exec'
const form = new Form(endpoint).then((event) => {
console.log('SUCCESS')
console.log(event)
}).catch((event) => {
console.log('ERROR')
console.log(event)
})
Node
var Form = require('form-google-sheets').Form
var endpoint = 'https://script.google.com/macros/s/AKfycbyEBGqfIUmxrLKMp_LlAlH8C_VO9vfRvtvwgjAS9lEi8Vu8xho/exec'
var form = new Form(endpoint).then((event) => {
console.log('SUCCESS')
console.log(event)
}).catch((event) => {
console.log('ERROR')
console.log(event)
})
Javascript
<script src="form-google-sheets.js"></script>
var endpoint = 'https://script.google.com/macros/s/AKfycbyEBGqfIUmxrLKMp_LlAlH8C_VO9vfRvtvwgjAS9lEi8Vu8xho/exec'
var form = new FormGoogleSheets.Form(endpoint).then(function(event) {
console.log('SUCCESS')
console.log(event)
}).catch(function(event) {
console.log('ERROR')
console.log(event)
})
Testing
Google Scripts
There is a test function setup that you can change to include your own fields and make sure your form is setup correctly.
- Change the testData in test_post()
- Move to Run in the top menu
- Click function test_post()
Client library
# Run unit test
yarn test
Releasing
# Create new versioned release
yarn run release
Examples
You can see examples of use in javascript under /docs.
You can see the (view only) sheet that this posts to here: https://docs.google.com/spreadsheets/d/1SRRfFOpIJyW6tZB1TP3wJf01CFISviIMFEJDgwoqq5w/edit?usp=sharing
Original Source
https://github.com/dwyl/html-form-send-email-via-google-script-without-server
Contributing
All contributors are welcome, please follow CONTRIBUTING.md