Google Apps Script web app that uses Sierra API to create patron records. Created by Brendan Lawlor for test purposes only. Use at your own risk. Not supported by CLAMS.
https://nodejs.org/en/download/
npm install @google/clasp -g
https://script.google.com/home/usersettings
git clone https://github.com/b-lawlor/Library-Card-Registration
cd library-Card-registration
clasp login
clasp create --title "Library Card Registration"
choose standalone
clasp push
clasp open
In api.gs
var baseUrl = "https://YOUR-DOMAIN.org/iii/sierra-api/v5/";
In main.gs:
processForm handles the data send from the html form
newPatron = {} //this is the JSON patron object we post to the API
getExpirationdate() returns an expiration date of 30 days from today
index.html contains the form and is served by the doGet function when someone visits your web app
javascript.html gets included in index.html and has some functions associated with the form
This line calls the serverside processForm function with a success handler call back function:
google.script.run.withSuccessHandler(confirmation(data.email)).processForm(data);
- Go to File -> Project properties
- Open the Script properties tab
- Click + Add Row
- Add a property with the name key with a value of your API key
- Add a property with the name secret with a value of your client secret
- Click Save
- Run-> Run function -> main
- Click Allow
- You will see an error, don't worry about it though
- Go to Publish -> Deploy as web app
- Copy the Current web app URL
- Anytime you update code you need to redeploy a new version of the web app for the changes to go live on this URL
- Select Project version -> new
- Set Who has access to the app, Anyone even anonymous for a public form or Anyone within my domain for a staff tool
- Click update