Adding Multiple find requests in Servoy

When a user puts a find request, Servoy internally creates a resulting SQL query to fetch data from database.

Let us check an example to know how this find request works. (Considering the currentController is based on the same table)
Let us check an example to know how this find request works. (Considering the currentController is based on the same table)

General Search SQL :

SELECT * FROM table1 WHERE field1=10; Servoy : if (controller.find()) { field1= 10; controller.search();

}

Search with AND operation SQL : SELECT * FROM table1 WHERE field1=10 AND field2=20; Servoy :

if (controller.find()) { field1= 10; field2 = 20; controller.search();

}

Search with OR operation (Multiple find request in coding) SQL : SELECT * FROM table1 WHERE field1=10 OR field2=20; Servoy :

if (controller.find()) { field1= 10; controller.newRecord(); field2 = 20; controller.search();

}

Let us consider a list view form with New, Duplicate, Find, Search buttons, where every button is attached to corresponding methods to create new record, duplicate record, to enter in find mode, to start search respectively.

When we are not in the find mode the New button creates a new record and Duplicate button duplicates the selected record. But when we are in find mode we are expecting these methods to create and duplicate the find requests respectively, which doesn’t happen. This is because of the way Servoy works in find mode. Once a form goes to find mode Servoy never executes any method where the code controller.search() is not found.
Solution to the problem:
In the methods for New and Duplicate button we can place a line of commented code for controller.search().

Example of the method attached to New button: function createNewRecord (event) { controller.newRecord(); // controller.search();

}

The commented code will enable Servoy to execute the method “createNewRecord” in find mode also, to create a new find request. The same style of coding can also be done for Duplicate button, which will duplicate the current find request , when the controller is in find mode.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!