# Modifying related data using scripts

**URL:** https://community.dreamfactory.com/t/modifying-related-data-using-scripts/1134
**Category:** Server-Side Scripting
**Created:** [May 26, 2015, 4:12pm UTC](https://community.dreamfactory.com/t/modifying-related-data-using-scripts/1134 "2015-05-26T16:12:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)
#### Post date: [May 26, 2015, 4:12pm UTC](https://community.dreamfactory.com/t/modifying-related-data-using-scripts/1134/1 "2015-05-26T16:12:17Z")

</div>

Hi,

I am wondering if it is somehow possible to modify the related data from a request somehow using scripts.

```
function initialise(randomId)
{   
    var uniqueUserId = randomId;
    var queryString = getDate()-172800;
    var filter_data = {"order": "startdate ASC" , "related": "eventmaster_by_eventid" , "filter": "enddate>'" +queryString+ "' AND status='1' AND uuid='" +uniqueUserId+ "'"};
    var request = platform.api.get("appname/mfavourites",filter_data);
    return request;
}

result = initialise(event.randomId);
return result;

```

I am trying to modify the startdate field of the eventmaster table which is linked by eventid.

---

<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:44pm UTC](https://community.dreamfactory.com/t/modifying-related-data-using-scripts/1134/2 "2015-05-27T15:44:03Z")

</div>

Yes, it is certainly possible. Any modifications to related data you can make through API calls may be done from a script also. Here is our documentation on updating related data:

[https://github.com/dreamfactorysoftware/dsp-core/wiki/SQL-Related-Data#updating-the-related-data](https://github.com/dreamfactorysoftware/dsp-core/wiki/SQL-Related-Data#updating-the-related-data)

Once you get the update working through the API, you should have an easier time implementing the same in a script.

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

[https://github.com/dreamfactorysoftware/dsp-core/wiki/Server-Side-Scripting](https://github.com/dreamfactorysoftware/dsp-core/wiki/Server-Side-Scripting)
