# How to manipulate child data using server side scripting

**URL:** <https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137>\
**Category:** Server-Side Scripting\
**Created:** [May 27, 2015, 12:59pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137 "2015-05-27T12:59:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![whalan84](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@whalan84](https://community.dreamfactory.com/u/whalan84)\
**Post date:** [May 27, 2015, 12:59pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137/1 "2015-05-27T12:59:40Z")

</div>

I currently have the following script which manipulates the eventmaster\_by\_eventid field.

```
if (event.response.record) {
_.each(event.response.record, function (record, index, list) {
record.eventmaster_by_eventid = 'New Name Here';
});
}

```

This works, but I am trying to manipulate a child field of eventmaster\_by\_eventid (called status). I am only new to this stuff and just trying to get my head around it but I was hoping I could do this somehow such as below but I am obviously off track a little.

```
if (event.response.record) {
_.each(event.response.record, function (record, index, list) {
record.eventmaster_by_eventid.status = 'New Name Here';
});
}

```

Can anybody give me any direction with this… really need to sort it out quite urgently. Any help is appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [May 27, 2015, 3:45pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137/2 "2015-05-27T15:45:25Z")

</div>

I recommend you check [this thread](https://community.dreamfactory.com/t/modifying-related-data-using-scripts/1134?u=jeffreystables) where another user has a very similar question.

---

<div class="post-metadata">

**Author:** ![toddappleton](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/toddappleton/32/159_2.png) [@toddappleton](https://community.dreamfactory.com/u/toddappleton)\
**Post date:** [May 27, 2015, 4:06pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137/3 "2015-05-27T16:06:56Z")

</div>

In the foreach loop you can var\_dump the record. Then you can check the log file in dsp-core/log to see what objects and fields are available, and if there were any errors.

```
if (event.response.record) {
     _.each(event.response.record, function (record, index, list) {
         var_dump(record);
         record.eventmaster_by_eventid.status = 'New Name Here';
     });
 }

```

You have to make a database call using platform.api.put() to write the changes. I don’t see that anywhere in your script. See this wiki page for examples.

[https://github.com/dreamfactorysoftware/dsp-core/wiki/API-Access-via-Scripts](https://github.com/dreamfactorysoftware/dsp-core/wiki/API-Access-via-Scripts)

---

<div class="post-metadata">

**Author:** ![whalan84](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@whalan84](https://community.dreamfactory.com/u/whalan84)\
**Post date:** [May 27, 2015, 10:35pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137/4 "2015-05-27T22:35:53Z")

</div>

Hi Todd, the fields all seem to be there when using var\_dump. I am just still unsure how to access them.

I should mention this is an event get.post\_process script… trying to access the values so I can pass the values to another script without modifying the database at all.

---

<div class="post-metadata">

**Author:** ![whalan84](https://avatars.discourse-cdn.com/v4/letter/w/ebca7d/32.png) [@whalan84](https://community.dreamfactory.com/u/whalan84)\
**Post date:** [May 27, 2015, 10:55pm UTC](https://community.dreamfactory.com/t/how-to-manipulate-child-data-using-server-side-scripting/1137/5 "2015-05-27T22:55:26Z")

</div>

Thanks Todd and Jeffrey for your help. I appreciate it a lot. It turned out

```
if (event.response.record) {
_.each(event.response.record, function (record, index, list) {
record.eventmaster_by_eventid.status = 'New Name Here';
});
}

```

actually does work… I am unsure what I was doing to think that that wasn’t working but it infact does. I am loving DreamFactory. Thanks again.
