Modifying related data using scripts


#1

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.


How to manipulate child data using server side scripting
#2

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

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/Server-Side-Scripting