On the Studio, there is a feature that allows you to perform basic form activities like the CRUD actions in offline mode. So, basically, when a user is filling up a form and he faces some internet issue, due to which the user goes offline, with this feature of Offline Submission the user will be able to make requests to perform tasks from the form. These requests can vary from inserting new data to deleting data.
Allow Offline
You can find this Allow Offline toggle while configuring server-side actions. This will enable the microapp to perform the offline submission.
On toggling ON of Allow Offline the Don’t wait for response toggle will get on automatically.
Don’t wait for response
On enabling of this toggle, you will not receive any response after the execution of this particular action block.
You can toggle it on separately.
NOTE: When you enable offline submission, the on-screen actions will be skipped. Also, you won’t be able to use the output variables from the response of one action block into another. There might be cases that file uploads and some other API calls might not work as expected.
Studio has a MODE keyword which can be used in actionflow to check whether the device is online or offline while opening the app.
Explanation of offline submission
The feature of offline submission is mainly built for mobile apps with package files only.
If there is a micro mobile app of a form with offline submission enabled, and the user tries to interreact with the app without the internet. The user can still submit the form, this will generate a toast message. Later, once the internet is available on the device, the API call will resume and it will carry forward with the request.
When the user sends/submits data in offline mode, it gets saved in a local database and then when the user is online and the app is reopened, the user will get a success message.
Working of offline submission
Let’s create a form, where the new data can be submitted to the database with a submit button and this will have the offline submission feature included.
The ideal case to build the action flow for offline submission is to maintain two branches for – ONLINE and OFFLINE mode.
-
Create two branches with the Branch On-Screen action. One leg of the branch will be executed when the system is ONLINE and the other branch will be in action when the system is OFFLINE.
Online Branch- It will have the following condition: {{MODE==‘online’}}
This branch will be in action when the system is online.Offline Branch- It will have the following conditions: {{MODE==‘offline’ && DEVICETYPE!==‘web’}}
This branch will be executed when the system is offline as well as not in web-app mode.This feature is specifically designed for mobile apps.
The sole purpose of this branching is to carry forward with action blocks, present only under the ONLINE mode branch since when you enable offline submission under the OFFLINE branch, the on-screen actions will be skipped.
-
Add the desired server-side action under the ONLINE branch followed by on-screen actions.
The alert responses (of error and success) you are seeing in the above image, are generally the response we get from any API call.
-
Add the desired server-side action under the OFFLINE branch followed by no on-screen actions. While adding the server-side action, enable the toggle button of Allow Offline.
NOTE: On enabling the Allow Offline toggle, it will by default enable the Don’t wait for response toggle button, thus irrespective of whether the user is online or offline, the user will not get any sort of response.
-
Now save the app, and try to submit data in offline mode.
A pop-up of success can be viewed stating that your offline submission has been registered.
NOTE: You can send multiple requests in offline mode. -
Now close the app fully and switch on the internet. Reopen the app. When you reopen the app, the DHQ add request function gets initialized, therefore all the pending requests get executed one by one.
You will view a success pop-up getting displayed, stating that your offline requests are successfully fulfilled.
Working/Non-Working exceptions of Offline Submission feature
- It will work only on mobile apps, not on desktop or web apps.
- Non-dependent action blocks only can be used. These are the actions that are not dependent on a response from any particular API/DB call. Example: connectors which we use for storing IDs and names.
- The on-screen actions will be skipped present after the offline block.
- You won’t be able to use the output variables from the response of one action block in another. There might be cases in that file uploads and some other API calls might not work as expected.