# Related param is ignored when trying to access api through event script

**URL:** <https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076>\
**Category:** Server-Side Scripting\
**Created:** [January 22, 2016, 2:56pm UTC](https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076 "2016-01-22T14:56:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ysadiq](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/ysadiq/32/158_2.png) [@ysadiq](https://community.dreamfactory.com/u/ysadiq)\
**Post date:** [January 22, 2016, 2:56pm UTC](https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076/1 "2016-01-22T14:56:27Z")

</div>

Hello all,

I’m trying to access api with related params through POST pre-process script,  
but the related param is ignored, no related object is returned.

this is my request

```
var filter_params = {"related":[{"name":"voucher_redemption_by_voucher_id"}]};                   

var voucher = platform.api.get( "blu/_table/voucher", filter_params);
throw JSON.stringify(voucher);

```

i tried to set \* to related to get all, but still none related object is returned.

to found a way around this, i added GET pre-process script to table voucher that should append a related param like below

`event.request.payload.resource[0].related = [{"name":"voucher_redemption_by_voucher_id"}];`

but this error is returned  
`> Cannot read property '0' of undefined`

currently using:  
Admin Application Version: 2.0.6  
DreamFactory Version: 2.0.4

am i doing it wrong?

Thank you

Yahya

---

<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:** [January 22, 2016, 3:44pm UTC](https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076/2 "2016-01-22T15:44:26Z")

</div>

You can add it directly to the url like this.

`var voucher = platform.api.get( "blu/_table/voucher?related=voucher_redemption_by_voucher_id");`

---

<div class="post-metadata">

**Author:** ![ysadiq](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/ysadiq/32/158_2.png) [@ysadiq](https://community.dreamfactory.com/u/ysadiq)\
**Post date:** [January 22, 2016, 4:05pm UTC](https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076/3 "2016-01-22T16:05:58Z")

</div>

Thank you todd, adding it directly to the url works.

one more question, how can i append related param in pre-process GET script, i tried using event.request.payload.resource[0].related, but it failed?

`event.request.payload.resource[0].related = [{"name":"voucher_redemption_by_voucher_id"}];`

error retuned

> Cannot read property ‘0’ of undefined

thanks again

---

<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:** [January 22, 2016, 4:47pm UTC](https://community.dreamfactory.com/t/related-param-is-ignored-when-trying-to-access-api-through-event-script/2076/4 "2016-01-22T16:47:09Z")

</div>

You can modify event.request.parameters like this.

`event.request.parameters.related = "voucher_redemption_by_voucher_id";`

But there’s a bug where modifications to the request object do not stick. It should be fixed by next week.
