From Servoy 7.3 onwards a Servoy developer can do a remote search for a specific foundset being in find mode and has findstates applied.
This allows to work with live data on the server, like foundsets with a million records.
In This Chapter
The Servoy find/search concept is extended to start with a local find and utilize a server side search.
Usage Client Side
In the mobile solution you set a foundset into find mode and then add some criteria then instead of calling search() on the foundset, call remoteSearch on the mobile plugin:
The successCallback and errorCallback params are functions that are called when this remoteSearch is done because this call is an a-synchronize call to the server.
On success the retrieved foundset as argument is not the same foundset started the find() on, but a new one similar to the one from databaseManager.getFoundSet().
This new foundset should be loaded into the UI by the success function as shown below. Note: returning a new foundset is intentionally to prevent remote search result to touch the UI.
The success and error callbacks have the following signature:
Needs Server Side
The plugins.mobile.remoteSearch() will call the service solutions 'offline_data' form 'ws_create()' method with the following signature:
This method is called by the remoteSearch call from the client and the OfflineDataDescription object that is returned will be merged into the current synced set the mobile client already has.
For all the pk's that are returned the service solution will be ask for to get the latest data for the Record.
If that record is changed on the client, the record data that the client had will be kept, to not delete changes the client made to it. If that is not the case then the local storage is updated with the new record data.
The foundset passed to remote search will go out of find mode and the remote filtered foundset will be given to the successCallback function.
All other global/shared foundsets will have all the new records and the existing records loaded, related foundset will be exactly the pk set that the server did return for it. Except new records on the client side, those will be inserted back in.
This does result in that the set of data in the mobile client does grow with every remoteSearch() call that gets new records, so calling clearData(), loadData() or doing a full sync() at certain times is recommended.