Quantcast
Channel: DreamFactory Forum - Latest posts
Viewing all articles
Browse latest Browse all 5028

Update field using PreProcess scripts

$
0
0

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

dump_var(event.request.payload.resource)

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 ) {
        var_dump(record);
        record.title = 'not alice';
        record['title'] = 'not alice 2';
        var_dump(record);
    });
}

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

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


Viewing all articles
Browse latest Browse all 5028

Trending Articles