Article

Mobile app view (view in sqlite)

Question

How do views work in a mobile application? When importing data in offline mode, views are saved to the database as regular tables. It is necessary to filter the field for which the lookup is a view. The view uses records from two sections (Accounts and a custom Construction Objects section). It turns out that when a new account is added in the desktop version, it shows up in the view and can be filtered by it. When creating a new account in the offline mode of the mobile application in the view, it shows up only after synchronization, which complicates the user's experience. As far as I understand, SQL-Lite has the ability to work with views. Is it possible to implement the functionality of views?

Bpm'online application version 7.9.2 2410. Mobile application version 7.11.7.

Answer

SQLite has the ability to create a view. To do this, you need to run the script to create a view in the configuration module. Create the module itself and add it to the manifest in the CustomSchemas block.

Code example:

var sqls = [“CREATE VIEW IF NOT EXISTS AccountView (Id, Name) AS  SELECT Id, Name FROM Account”];
Terrasoft.Sql.DBExecutor.executeSql({
   isCancelable: false,
   sqls: sqls,
   success: function() {},
   failure: function() {}
});

It will be quite difficult to implement filtering by view in the card, so you will still have to write a custom business rule that will make a request for the view.

By default, we do not work with SQLite views. It makes no sense, because the representation in MSSQL or Oracle may not be the same as the SQLite implementation. A view in a mobile application is a regular table, therefore you need to work with it accordingly.

This means that if you want a value to appear there, you should add it. To do this, you can implement business rules for the “Account” and “Construction Objects” objects, so that when adding or updating a record, a copy of this record will be made in the desired view.

Like 0

Like

Share

0 comments
Show all comments