Creating a custom function


#1

Hi all;

I just got to know of DreamFactory and downloaded and installed on an Ubuntu desktop VM. I successfully connected to a local MySQL db and had API created by DF. Now I want to create some customer endpoints. I go to Scripts from teh top menu but do not have a ‘Create’ button. How do I proceed?

Please bear witha beginner.

Thanks
I.


#2

If you seek to create a script that is triggered on an API event, you will need to navigate on the left-hand side through ‘Process Event Scripts’ > {service} > {service.component} > {service.component.verb.trigger}, at which point the Script Type/Language selector, Active checkbox, and script editing window will be enabled.

E.g., if I wanted to create a script that is triggered prior to the service call every time the table called “todo” from the service called “db” was called with a GET verb, I would navigate to Process Event Scripts > db > db._table.{table_name} > [GET] db._table.{table_name} > db._table.todo.get.pre_process

If you wish to create a script service that is executed when it is called directly as an API endpoint, navigate to the Services tab and create a service with type ‘Custom Scripting Service’, then enter your script on the Config tab.

I recommend our tutorials, which walk you through creating two types of triggered scripts as well as a custom scripting service for each scripting engine that is available (V8 JavaScript, Node.js, and PHP).

Scripting Tutorials on the DreamFactory Wiki


#3

Thanks Jeffery. This is just what I was looking for.

I.