Native Mobile: Synchronize Data on User Request

Good Day, We are currently building an application where a user can view products from a store. These products are not initially sync’d unless the user has added them to their favourite list. However, for the initial phase of the user viewing these products I have been unable to synchronize the products via the nanoflow activity or via a retrieve.  The ‘Sync to Device’ action called from microflows can’t be used with nanoflows, nor microflows receiving persistable entities that are being used in nanoflows, so I have had a hard time getting those microflows to work. Given the above, any help on how to synchronize objects to the users device that are not synchronized on start-up or included in the Xpath constraint for synchronization.
2 answers

Hi Brent,

In your case I would make a non-persistent entity with a string attribute to use as search helper.

Place this attribute on a page with a search button. When pressing the search button, call a nanoflow and use this non-persistent entity as inputparameter in your microflow. In your microflow you can search for the correct Products and sync these to the device.

Under the search field. Place a listview with Product to display them. You still need to figure out some other stuff, like when searching for a second time and not displaying the results of the first search. But that's for next time :)

We have a setup like this: 

In the searchresult place the basic attributes you would need to display in the results listview. Upon pressing search, send the helper to the backend, retrieve the correct objects, create searchresult objects for each found object. These get synced automatically to the client at the end of the microflow (you can't sync non-persistent entities to device with an action). Retrieve them in your page. 


In terms of solving the limited search results on the second search that you mentioned, I solved this by using a microflow for the list creation. 

  1. The microflow would receive the search parameter object as a parameter
  2. Use those to search the local client database for the synced results (my product sync would take place on the search button)
  3. Return the list that was found