Synchronize the entity for offline Native mobile app

Hi,   I was working Native mobile app which needs to be worked on offline too. Problem I am facing is I need to delete certain records from entity during offline mode also. Since Nanoflow doesn’t have delete object action, I am calling microflow from Nanoflow to delete the objects. Whether calling microflow during offline process creates error or it will complete the flow without throwing error and once app came online deleted records will be syncronized ?   If calling the microflow during offline will cause error, is there any option to delete the records of entity which satisfies the condition boolen attribute ‘delete’ was true once app come online, like triggering the microflow to delete these records when ever app switches from offline to online ?   Thanks, Balaji S
3 answers

Hi Balaji,

When you are working on offline use one boolean attribute(isDelete) for the object which you are trying to delete.

Try to change that boolean(isDelete) value as true when you processing delete action for that object in offline.

In sync flow, use microflow and retrive objects with isDelete=true as Xpath constraint and delete the retrieved datas. 


Hi Balaji Sekar,

                       Whenever commit the objects using your offline application, everything will be stored in our mobile device local storage. So when the user enables the internet connection, we need to do a Synchronization process to maintain the data consistency. For example, Person A applied for leave using his mobile phone without an internet connection (Offline mode). The same user logging into his same web application. When he checks his leave portal, it should display the created Leave object. For this purpose, we need to do the Synchronization process.

   Suppose, user wants to delete the created leave object means, we need to create one boolean attribute in that Entity ( isDeleted ). When a user clicks on the delete button, call the nanoflow to set that particular object's (isDeleted) value from false to true. Add the data source nanoflow to filter the isDeleted = false lists and return that list.

When the user gets back online, we need to identify, whether the user has an internet connection that is ON or not using JavaScript action. 


The synchronization process only works, if the user has an internet connection. Otherwise, it will throw an error.  If the user wants to do Synchronization process manually, we can use this JS action return value to determine execute the Sycnhronization process or intimate user to turn on internet connection. 

Before  synchronization process happen, we need to remove the [isDeleted = true()] lists. Because, these lists are needs to be deleted from local storage and continue with Synchronization activity. 



Finally, do the Synchronization process like this.



I hope, it will help you.


Thanks and regards,

Vijayabharathi V






Calling a nanoflow when there is no connection will cause an error, so always check with the isConnected JS action from NativeMobileResources module before you do that.

But deleting them on the server won't automatically delete on device, so you would need to synchronize everything to remove them from the device.

In most cases we work with an IsDeleted boolean on the object, and filter these objects from views and logic. Then in an event handler microflow on the entity (after commit) check this boolean and delete if necessary when we synchronize everything. We also have access rules on the entity that users can only read/write objects where ‘IsDeleted = false()]. This also prevents the ‘deleted’ objects from getting synced to the device.

Good luck!