Update field using PreProcess scripts


I want to modify a field in a preprocess script but it is not working.

The script is

if (event.request.payload.resource) {

    lodash._.each (event.request.payload.resource, function( record ) {
    record.snapTypeID = 2;  

However that is never run because
event.request.payload.resource is null.

when i log:


I get for (event.request.payload):

object(Object)#2016481607 (2) {
[“title”] =>
string(4) “ssss”
[“description”] =>

and for (event.request.payload.resource):


Adding record to db problem

Hi @Matt_2012,

Try this way:

//check if u have a payload
if (event.request.payload) {
    //check if u have the key snapTypeID
    if (!event.request.payload.snapTypeID) {
        throw 'snapTypeID cannot be empty';
    } else {
        //we have the key, so change it
        event.request.payload.snapTypeID = 2;

I hope it helps


If you’re trying to create records, your payload should contain an array named ‘resource’.



Hi should the resource be where I update the data ?

I am getting closer but still not able to modify (change the title) in the record before it is added to the table.

I now have a resource array in the payload


array(1) {
  [0] =>
  object(Object)#220134100 (2) {
    ["title"] =>
    string(5) "Alice"
    ["description"] =>
    string(5) "Jones"

but I cant update the record in the script.

if (event.request.payload.resource) {

    lodash._.each (event.request.payload.resource, function( record ) {
        record.title = 'not alice';
        record['title'] = 'not alice 2';

event.request.payload.resource[0].title = 'not alice 3';
event.request.payload.resource[0]['title'] = 'not alice 4';
event.request.payload['title'] = 'not alice 5';

payload and resource are being changed but alice is still being submitted into the database.


Make sure you are editing the correct script depending on POST or PATCH, and that the scripts are marked as Active.

For example,





Hi Todd

Script definitely active and I am using post to add a new record.
It wouldn’t be appearing in my logs otherwise.

I can modify the resource object but not what gets added to mysql table.

What would be very helpful here is a working example where data is modified at the preprocess stage.

Many Thanks



I confirmed there is an issue here. I’m working with the dev team to resolve and will report back here with updates.


Any date, for this issue ?

I have the same with php script


Hi There,

I am still getting similar kind of issue. I am unable to update resource from event. below here is my event and code within event. I can validate the value but when I update the value of it, its not reflecting in db.

Event: mysql mysql._table.{table_name} mysql._table.{table_name}.post.pre_process mysql._table.employee.post.pre_process

console.log(event.request); // outputs to file in storage/log of dreamfactory install directory

// use NPM to install lodash
event.request.content_changed = true;
var lodash = require(“lodash”);

event.request.payload.resource[0].salary = 90;

Note: I have enabled both check boxes “Active” and “Allow script to modify request payload”. I am sure that Event is triggering because I can validate the data and throw errors.