# Generic server side script

**URL:** <https://community.dreamfactory.com/t/generic-server-side-script/3846>\
**Category:** REST API\
**Created:** [May 27, 2017, 1:05am UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846 "2017-05-27T01:05:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uurtsaikh201](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@uurtsaikh201](https://community.dreamfactory.com/u/uurtsaikh201)\
**Post date:** [May 27, 2017, 1:05am UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846/1 "2017-05-27T01:05:53Z")

</div>

Hello guys,

I would like to ask you guys about how can I write more generic script which works with all of PUT requests or POST requests.

For example, I want to write the history of all actions of my services to the audit table.

In the server-side scripting, it is possible to write the script code table by table (resource by resource), and I need to have more generic scripting possiblity.

Thank you

---

<div class="post-metadata">

**Author:** ![juniorconte](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/juniorconte/32/1007_2.png) [@juniorconte](https://community.dreamfactory.com/u/juniorconte)\
**Post date:** [May 28, 2017, 11:32am UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846/2 "2017-05-28T11:32:48Z")

</div>

Hi, @uurtsaikh201

I think the most generic it could be, would be through the entry points of `{table_name}` and `{table_name}.{id}` service by service (diferents databases), and verb by verb (POST, PUT, PATCH, DELETE).

**Step 1 (selec `{table_name}` and `{table_name}.{id}` events)**  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/dreamfactory/original/2X/6/6dfc8bdfff9abf22e1c228f5f84282b4495f6d18.jpg)

**Step 2 (selec all verbs of writing) (repeat this step to `{table_name}.{id}`)**  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/dreamfactory/original/2X/1/122f11215a9287f22e32b4f31852fd87cb444a50.jpg)

**Step 3 (write your script) (The queue is optional, but consider to create async audit, if you not interest it, select pre or post process.)**  
 ![](https://canada1.discourse-cdn.com/flex035/uploads/dreamfactory/original/2X/d/d3efadc576d2def3826d964028c13ca2c019f362.jpg)

In this example, you need write the same script 8x (one to each verb “4” into `{table_name}` and `{table_name}.{id}`)

best regards,  
Junior Conte

---

<div class="post-metadata">

**Author:** ![uurtsaikh201](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@uurtsaikh201](https://community.dreamfactory.com/u/uurtsaikh201)\
**Post date:** [May 29, 2017, 3:32pm UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846/3 "2017-05-29T15:32:34Z")

</div>

Hello dear,

Thank you.

Do you think this code is generic?

For example, if I have 50 tables, then I would write script 200 times.

Is that correct?

Tom

---

<div class="post-metadata">

**Author:** ![juniorconte](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/juniorconte/32/1007_2.png) [@juniorconte](https://community.dreamfactory.com/u/juniorconte)\
**Post date:** [May 29, 2017, 8:50pm UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846/4 "2017-05-29T20:50:50Z")

</div>

The {table\_name} is alias to all tables, and is apply to all requests.  
In my example, all request of POST **1.C.SCRIPT** is applied to any requested table of service **museum**.

---

<div class="post-metadata">

**Author:** ![uurtsaikh201](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@uurtsaikh201](https://community.dreamfactory.com/u/uurtsaikh201)\
**Post date:** [May 29, 2017, 9:07pm UTC](https://community.dreamfactory.com/t/generic-server-side-script/3846/5 "2017-05-29T21:07:02Z")

</div>

Hello Junior Conte,

Thank you.  
Your right.
