This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteRecord(payload, done) { | |
payload.record = payload.data; | |
payload.record.form_id = "{FULCRUM SECOND FORM ID}"; | |
// this sets up the record id from the original form to the text field in the 2nd form | |
payload.record.form_values['{FULCRUM ELEMENT KEY}'] = payload.record.form_values['{FULCRUM ELEMENT KEY 2}']; | |
delete payload.data; | |
var query = encodeURIComponent("SELECT _record_id AS fulcrum_id FROM \"Table Name\" WHERE my_record_id= '" + payload.record.form_values['FULCRUM ELEMENT KEY'] + "'"); | |
request({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateRecord(payload, done) { | |
payload.record = payload.data; | |
payload.record.form_id = '{FULCRUM SECOND FORM ID}'; | |
// the line below equates the RECORDID() calculation field from the original form to the text field in the 2nd form | |
// so that we can use the query API to find the correct correct to update from the original form | |
payload.record.form_values['{FULCRUM ELEMENT KEY}'] = payload.record.form_values['{FULCRUM ELEMENT KEY 2}']; | |
delete payload.data; | |
var query = encodeURIComponent("SELECT _record_id AS fulcrum_id FROM \"Table Name\" WHERE my_record_id= '" + payload.record.form_values['FULCRUM ELEMENT KEY'] + "'"); | |
request ({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createRecord(payload, done) { | |
payload.record = payload.data; | |
payload.record.form_id = "{FULCRUM SECOND FORM ID}"; | |
// if you have a field that does not have the same element key for both forms then you can associate the fields | |
// with this line (I explain what this is for in more detail in the next block): | |
payload.record.form_values['{FULCRUM ELEMENT KEY}'] = payload.record.form_values['{FULCRUM ELEMENT KEY 2}']; | |
delete payload.data; | |
delete payload.record.id; | |
request({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `express` is a minimal and flexible web application framework that helps with routing logic. | |
var express = require('express'); | |
// `fulcrumMiddleware` is a library that lets you take some shortcuts for setting up Fulcrum webhooks. | |
var fulcrumMiddleware = require('connect-fulcrum-webhook'); | |
// `request` allows you to make REST calls to APIS so that you can get, add, update or delete data. | |
var request = require('request'); | |
// setting up the local port to listen on | |
var PORT = process.env.PORT || 9000; | |
// setting up the express framework | |
var app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fulcrumMiddlewareConfig = { | |
actions: ['record.create', 'record.update', 'record.delete'], | |
processor: payloadProcessor | |
}; | |
app.use('/', fulcrumMiddleware(fulcrumMiddlewareConfig)); | |
// this is for decorative purposes. It adds a little HTML to the front end of your URL so that you can check to make sure things are up and running | |
app.get('/', function (req, res) { | |
res.send('<html><head><title>The Webhook Script</title></head><body><h2>is Running!</h2><p>going</p></body></html>'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
id: "1371c81d-367b-45d3-9f7c-91da5de9518e", | |
type: "record.delete", | |
owner_id: "00053caf-4b6e-4c86-88b6-64695895dffe", | |
data: { | |
status: "Completed", | |
version: 3, | |
id: "7553fd44-78bb-41eb-a453-8b301ae5e52e", | |
form_id: "295eda4a-7795-4881-9f62-085a930b356e", | |
project_id: "Wetlands", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `express` is a minimal and flexible web application framework that helps with routing logic. | |
var express = require('express'); | |
// `fulcrumMiddleware` is a library that lets you take some shortcuts for setting up Fulcrum webhooks. | |
var fulcrumMiddleware = require('connect-fulcrum-webhook'); | |
// `request` allows you to make REST calls to APIS so that you can get, add, update or delete data. | |
var request = require('request'); | |
// setting up the local port to listen on | |
var PORT = process.env.PORT || 9000; | |
// setting up the express framework | |
var app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateStatus (recordID) { | |
var url = "https://api.fulcrumapp.com/api/v2/records/" + recordID + ".json?token=" + fulcrumAPIkey; | |
var options = { | |
"method": "GET", | |
"contentType": "application/json" | |
}; | |
var recordJSON = UrlFetchApp.fetch(url, options); | |
// Update record with status info | |
var record = JSON.parse(recordJSON); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateDate (recordID, date) { | |
var url = "https://api.fulcrumapp.com/api/v2/records/" + recordID + ".json?token=" + fulcrumAPIkey; | |
var options = { | |
"method": "GET", | |
"contentType": "application/json" | |
}; | |
var recordJSON = UrlFetchApp.fetch(url, options); | |
// Update record with wx info | |
var record = JSON.parse(recordJSON); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loopThrough(records){ | |
var myDateString = Utilities.formatDate(new Date(),"GMT", "yyyy-MM-dd"); | |
for (var i = 0; i < records.length; i++) { | |
var formattedDate = records[i].updated_at.substr(0, 10); | |
var now = new Date(); | |
if (formattedDate === myDateString) { | |
now.setDate(now.getDate() + 30); | |
var stringDate = Utilities.formatDate(now,"GMT", "yyyy-MM-dd"); | |
updateDate(records[i].id, stringDate); |
NewerOlder