Question about offline mode on mobile

Hi:

In the documentation for offline reads this:

"Queries configured to read data for offline mode only cache data when the user views the results. The user must navigate to screens and view the query data at least once while connected."

In my use case I'm connecting to a Azure SQL database; each morning I'll run an automated script to delete all data from this database and populate with related data for the day, in my case deliveries.

Our drivers will have the application and they'll go in select their name (screen 1) on the second screen will be a list of "drops". After selecting the current drop a list of labels to be scanned will appear a textbox on top they'll scan the barcodes using their phones. Once scanned it will update the data with the driver's name, scanned timestamp and scanned = true. Once finished they'll go back to the drop list and select the next drop and so on.

My question is based on the statement in the documentation. Will they have to go to each drop to be able to use it offline or just one drop since it will just be a result of the selected drop? This offline mode is important in my use case because my drivers for sure will go to far locations where there's limited connection or none.

Thank you. I'm hoping it works that way because I'm liking this platform a lot.

Hi @adominicci,

Yes, your drivers will need to go to each drop in order to be able to use it offline. This is because Retool caches data for offline mode only when the user views the results.

However, there is a workaround that you can use to make this work for your use case:

  1. Create a screen that lists all of the drops for the day.
  2. Configure this screen to cache data for offline mode.
  3. Have your drivers navigate to this screen at least once while they are connected to the internet.

This will cache all of the drops for the day, and your drivers will be able to view them offline even if they lose their internet connection.

Here are the steps on how to configure a screen to cache data for offline mode:

  1. Go to the Screens page.
  2. Click on the screen that you want to configure.
  3. Click on the Settings tab.
  4. Under Offline mode , check the box next to Cache data for offline mode .
  5. Click Save .

Once you have configured the screen to cache data for offline mode, have your drivers navigate to this screen at least once while they are connected to the internet. This will cache all of the drops for the day, and your drivers will be able to view them offline even if they lose their internet connection.

Hope this helps.

:grinning:

Patrick

1 Like

Hi @PatrickMast thank you so much for this detailed explanation. I know I'll have only like 4 screens. Do you think is doable to maybe take the first screen and somehow have hidden lists when loading the first screen?

It is only a subset of data for the day so there won't be more than 400 records all together. Again thank you so much. I really appreciate it.

:grin:

Hi @adominicci,

Yes, it is doable to have hidden lists on the first screen to cache all of the drops for the day. This would allow your drivers to view all of the drops offline without having to navigate to each one individually.

Here are a few possible approaches:

  1. You could use a hidden repeater to display all of the drops for the day. You would need to configure the repeater to fetch the data from the Azure SQL database and to cache the results for offline mode. You would then need to set the repeater's visibility to hidden.
  2. You could use a hidden table to display all of the drops for the day. You would need to configure the table to fetch the data from the Azure SQL database and to cache the results for offline mode. You would then need to set the table's visibility to hidden.
  3. You could use a hidden JSON object to store all of the drops for the day. You would need to populate the JSON object with the data from the Azure SQL database and then set its visibility to hidden.

Once you have hidden the drop list on the first screen, you would need to write some custom code to load the drop list when the driver first opens the app. You could do this by using a lifecycle hook or by writing a custom action.

Here is an example of how to use a lifecycle hook to load the drop list when the driver first opens the app:

// Get the drop list from the hidden JSON object.
const dropList = JSON.parse(state.dropList);

// Set the drop list in the state.
setState({ dropList });

Here is an example of how to use a custom action to load the drop list when the driver first opens the app:

// Load the drop list from the hidden JSON object.
const dropList = JSON.parse(state.dropList);

// Set the drop list in the state.
setState({ dropList });

// Navigate to the drop list screen.
navigate('/drops');

Which approach you choose will depend on your specific needs and preferences. I recommend that you experiment with the different approaches to find the one that works best for you.

I hope this helps!

:grinning:

Patrick

1 Like

I'm so grateful @PatrickMast you took the time to even come up with different options. I really appreciate it. I'll try different scenarios as you suggested and come back later to let you know what I did and what worked best. Thank you again.

Andres

:hugs:

3 Likes

You are welcome!

:grinning:

Patrick