V8 custom formulas
From DreamFactory
Make a field automatically be a mathematical result. Return 'total' as JSON key with value 'price' * 'tax_rate'. price and tax_rate are stored in a database, total is not.
var lodash = require('lodash.min.js'); lodash._.each(event.response.content.resource, function (record) { if (!record.tax) { throw "Tax is required!"; } if (!record.price) { throw "Price is required!"; } record.total = (parseFloat(record.tax) * parseFloat(record.price) / 100) + parseFloat(record.price); });