Auto Sync Local Storage
Question
Application Type
Mobile

Hi,

I have a Database Entity which is replicated to a Local Storage entity . This database entity is more like a static in nature but there could be a change once in a month or like that. 

Is there a way to perform a automatic Sync between Database and Local Entity if there is any change in database

There are three ways will do the syncing.

1. BPT (Business Process Technology) - This will ONLY trigger when there's any Created (or Updated) data in your database.
2. Do a server logic (sync) and call it after a successful login.
3. Timer - Disadvantage is, you will run this process for a specific time you want (example every 12am). You can set this up on service center. But you can also manually trigger on service center as well or wake-ing the timer during runtime using your action.

To give you an overview about BPT:

• Under Process tab Right click and Add Process
• Drag Automatic Activity node, Double click the activity and put your server logic of database syncing.

Note:
Launch On property is the trigger (to do the syncing logic) when there is a Created data on your database.
CreatedUser is a database event of User database table.
• You need to set your Database to be available on Launch On property. See below on how to set


Hope this will help!

Marco

Thanks Marco for the detailed solution. 

If I implement the BPT solution, i am confused how it will be effective on individual users?

For example, in my case, what i need is to make the changes happened in database locally available to every device that is running this application. How does this automated process work in individual device and make sure this sync happened in every device?

Champion

Hi Learn It,

You can apply Batch Synchronization that will help to synchronize data once in a month. Your core module has a timer to regularly synchronize information through the module (or integration service where DB is integrated ).

 Here in this diagram, timer is inside core module where your local entities are available. It will synchronize data from Customer_IS module once in a month.

 

Another pattern is,  you can isolate timer in synchronization module. There are many patterns that can be performed according to your how synchronization tuning and how's  summary fields changing. 


Check this for mobile - https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Offline/Implementing_Offline_Sync


Hope this help,

Rahul 

Champion

Hi Learn It, 

Initially I thought you have  external database entities and you are maintaining local entities so that you have less call to ext DB. That's why you wanted to replicate it in your local entities once in a month to improve performance. That's a reason I suggest you how we can improve performance by using outsystems architectural patterns. But after some time I see your application type and it is mobile. So, It is about local storage. That's why I paste a link of Offline sync documentation.

I encourage everyone who is exploring things and try to give answer as their understanding.  We will have to escape from any judgement.


Thanks and regards,

Rahul


Hi,

This seems you are having master data in Server that you want to sync in device. So you need to follow below steps

  1. You have one way data synchronization, need to only sync from server to device ...or you need to since from device to server as well.
  2. You can create a Localmetadata table in local and store last SYNCON datetime there once it sync from server.
  3. In server table you need to have attribute like CretaedOn or UpdateOn.
  4. So once you configure offlinesync SyncOnOnline or any other configurations or timer/Processes based on frequency to data change/ addition in server master table.
  5. Create a Server Sync action and pass lastSyncon time as input and Created and Updated record list as output
  6. Now first you need to pass LastSyncOn time from local to server and check if any new records added after lastsyncon time.
  7. If Yes, then get that records as newly created records as assign output from server sync actions.
  8. If there are any record updated after lastsyncon then get that records as updated.
  9. Final Create or update that records to local Entity based on output from server.


Hope it may help you.


,

Dileep 

mvp_badge
MVP

This reply from Dileep is the correct solution, not the previous two replies.

Essentially you keep track on the server record a last change datetime.

And locally a last syncdate time.

No BPT needed, nor an integration pattern with a timer.

Using offline sync configuration you can decide when your device should check for changes and start the sync in the background. 

mvp_badge
MVP

People can down vote my view point as much as they like, my statement stands, Dileeps solution is the correct reply and as far as I am concerned could be marked as solution.


Hi all,

First of all, I agree that the answer by Dileep is the correct one.

And yes, the other 2 answers give a lot of correct information about BPT and timers and integration synchronisation patterns, but they are absolutely in no way an answer to the question of this post. 

So I upvoted Dileeps and Daniels comments.  I try to avoid downvoting, but in this case, as the subject was advanced and the wrong answers might mislead beginning developers I have downvoted the other 2.

If this has contributed to a downvoting race that has nothing to do with the content of what is being said, I am sorry. 

Dorine

mvp_badge
MVP

Up and down voting, is available in the forum, to share if you think an answer is either a good or a wrong answer, this should never be about a personal like or dislike of the community member, it should be on the reply provided. 

Liking and disliking, will help other community members that need to scan through a discussion to filter out what replies are good or bad answers.

I personally try to like any answer on a discussion I think is a good answer. If the answer is less good, I would never down vote it. If an answer is clearly incorrect as it suggests something that is not relevant (like replying with a traditional web solution, while the original poster asks for a reactive web solution).

For every 100 likes, I maybe give 5 dislikes, definitely I like a lot more that what I dislike. However, there is a trend over the last half year that people try to help and provide answers without understand the question, or even ask any additional information before trying to think about a solution. A lot of questions ask lack a lot of detail for one to give a good answer. Rather than guessing, we should ask more context. That will help to have higher quality answers.

I understand people can feel offended if their reply is disliked, when they try to help, I know the feeling. Just don't take it personally. I have replies I made marked as bad too, more than once. In the end, they will be a fraction of all the likes you get. Whenever I get a dislike, I first go back to my reply and try to understand why the other person disliked it, and 99 out of 100 times I learn from it. Sometimes you don't understand, and that is ok too. We do not have to agree on everything. But what I would never do is take it personally.



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.