Outsystems mobile app : Database operation fails with error

Outsystems mobile app : Database operation fails with error

We created a sample mobile application with the help of OutSystems 8.9 (Beta version) ; packaged for android via cordova (version3.5.1).
We needed to interact with local database for which we included a sqlite plugin ( plugin ref: https://github.com/brodysoft/Cordova-SQLitePlugin).  
The app simply creates a local database in the preparation of a OutSystems page and loads it with data. We have a button to add one particular record in the database.
Issue that we are facing is that the database operation fails most of the time with error:  “An exception occurred in the client script. Error: Object # has no method ‘exec’.
Any help towards solving this issue would be greatly appreciated.
Hi Rajni,

I would suggest that you run the application on your device connected to your computer, and with Chrome dev tools try do debug what is going on and test the javascript on the console.

It appearts that you tryed to execute an action in an invalid object. Double check that you passed the right object id into your function calls.
Hi Marco,

I have already checked on chrome dev tools, it is failing in SQLitePlugin.prototype.open method of SQLitePlugin.js file at this line:
     cordova.exec(onSuccess, error, "SQLitePlugin", "open", [this.openargs]); 
Here it is unable to find exec method and hence throws the error: Object #<Object> has no method 'exec'.

I haven't tryed that plugin, but you can run the open command differenty: window.sqlitePlugin.openDatabase
Also test if window.sqlitePlugin is not null. 

Another thing you need to consider is the loading of the plugin(s). If you open any plugin web block from the Native module, you will see that inside that web block, there is another one called NativePluginLoader. If you wish to use your plugin without any web block, you can put this directly on your screen, but I would advice you to create a web block for your SQL Lite plugin and add it there.

The NativePluginLoader web block instructs OutSystems Now that you will be using native functionalities, so OutSystems Now will load the cordova plugins. We have done this to optimize all other screens where native functionalities are not being used.

Hi Marco, 

1. We have indeed been using window.sqlitePlugin.openDatabase to open the database.

2. We are loading SQLite plugin via same procedure as you have advised.