Methods
Last updated
Last updated
Servoy provides functionality to add methods at the data model layer. Giving developers the opportunity to implement validation and or business logic bound to an entity.
In order to get started with methods. First select a database server and a table. Then find the methods tab. From there we can click add to create or update a method for the entity.
First select a Module/Solution that you want to add the method to. Then click "Add" and give a name to the method. After saving, we can then double click the "Source" column to access the scripting for the method. This will open up the entity scope associated with the table. It should be pointed to the method you selected.
First Open up the methods screen for the selected table. Then double click the "Source" column to access the scripting for the method. This will open up the entity scope associated with the table. It should be pointed to the method you selected.
Within the entity we have access to the core foundset API for a particular datasource. This means we don't have to use the foundset keyword. It's implied. For example if you wanted to get or load a particular record in memory, we could simply call getRecord(index). Without using the foundset keyword.
Entity methods can be executed wherever the datasource is referenced. This means you could use it within a form that has the datasource connected. Or in a global scope if we are refering to a separate foundset. If within a form's script context, just use the foundset keyword + the name of the entity method. For example, foundset.my_method().