# Custom scripts understanding

**URL:** https://community.dreamfactory.com/t/custom-scripts-understanding/530
**Category:** Server-Side Scripting
**Created:** [November 5, 2014, 7:40pm UTC](https://community.dreamfactory.com/t/custom-scripts-understanding/530 "2014-11-05T19:40:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![krzysztofweglinski](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@krzysztofweglinski](https://community.dreamfactory.com/u/krzysztofweglinski)
#### Post date: [November 5, 2014, 7:40pm UTC](https://community.dreamfactory.com/t/custom-scripts-understanding/530/1 "2014-11-05T19:40:39Z")

</div>

I don’t quite understand server side scripting,  
I know theres documentation for this, but got problems getting through.

Just want very simple script. ☹  
When user add data to table A (through restAPI),  
then get part data of that call and put it into another. (Notifications)

So I thought it’ll be simple as that:  
if (event.response.record.lenght) {  
\_.each(event.response.record, function(record, index, list) {  
var data = {“to”: [record.to](http://record.to), “type”: 1, “set”: record.plan\_id, “who”: record.user\_id};  
platform.api.post(“plansth.notifies”, data);  
});  
}  
plansth is app and service name, the rest lok quite obvious.  
Where did I go wrong?

---

<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: [November 6, 2014, 2:27pm UTC](https://community.dreamfactory.com/t/custom-scripts-understanding/530/2 "2014-11-06T14:27:14Z")

</div>

You have a typo in event.response.record. **lenght**

In platform.api.post(“plansth.notifies”, data) is your service API name “plansth.notifies”?

To help with debugging you can use print and var\_dump to write to the log file in the /log directory of your DSP.

---

<div class="post-metadata">

### Author: ![krzysztofweglinski](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@krzysztofweglinski](https://community.dreamfactory.com/u/krzysztofweglinski)
#### Post date: [November 6, 2014, 5:55pm UTC](https://community.dreamfactory.com/t/custom-scripts-understanding/530/4 "2014-11-06T17:55:06Z")

</div>

.Och, right, I often make this typo (don’t know why only with lenght).  
my API name is plansth tablename is notifies

I’ll try this logging, thanks.

---

<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: [November 6, 2014, 6:30pm UTC](https://community.dreamfactory.com/t/custom-scripts-understanding/530/5 "2014-11-06T18:30:59Z")

</div>

No worries I’ve made the same typo before 😄

In platform.api.post() you want to use service/resource which in your case would be plansth/notifies.

/ not .
