Offline Availability
When you create an Application Form or use a form in a workflow task, you can set the form to be available offline. This allows you to open forms and action tasks in K2 Mobile when you are not connected to the server. When K2 Mobile is connected again, the forms are actioned and submitted. In addition, you can configure certain list controls to cache their data which is downloaded when the form initializes. This is especially useful when you need data, such as drop-down lists and picker controls, to be available when the device is offline.
If you do not enable the Offline Availability form property, the form is only available when the K2 Mobile app is online.
The following scenario uses a workflow form as an example. Follow the steps to create an offline form using K2 Designer:
- Edit a form linked to an existing workflow.
- Navigate to the Layout tab.
- Expand the Advanced section of the form's properties.
-
Check the Offline Availability property. This makes the form available offline in K2 Mobile.
- If you use list controls on your view or form, you can cache the data so that these controls are populated before you go offline.
- Navigate to the Rules tab.
Make sure that all actions that need to communicate with the server to load the form are in the initializing event.
-
Edit the When the Workflow View is being submitted rule and change the execution type to then complete the following in a batch. See Rules, Events and Actions and Considerations for information about using rules with offline forms.
- Click Finish to stop editing the form.
- Open the K2 Mobile app.
- Open the Task List in K2 Mobile and open the form. You have to open the form at least once before you go offline.
- Note that if you put your device in airplane mode, you can still open and action the task.
If you have no internet connection on your mobile device or if the K2 Mobile App is offline, an Offline Mode status displays in the Task List. See the Task List and Task Card Detail topics for information about the options that are available when your form is offline.
When you mark a form for offline availability, you have the option to cache the data on certain list controls such as the Drop-Down List control. This allows you to work offline with data that is already downloaded and allows the form to be filled out even when the device is offline.
When you enable the Cache the data setting of a list control, data is downloaded and cached when K2 Mobile is online and the form initializes. This means that you must load all the data you need during initialization by checking the Cache the data check box of the control's data source. See Client side filtering, How caching is applied and How cashing is applied with cascading data.
If you load data in the initializing event then you don’t need to use the Cache the data option. However, if you need to filter a list control at a later point using manual input such as cascading data, then you must use the Cache the data option. It is a good idea to enable the Cache the data setting for all drop down controls and picker controls when designing forms for offline use. The setting is available on the following controls:
If a form can potentially return large volumes of data, it is advised NOT to use the Offline Availability setting as this can slow the form down the first time it's opened. For example, if a user manager such as Azure Active Directory contains 3000 users, setting the user picker’s data source to work offline will result in slow performance when the form initializes.Use the following notes for how to configure rules with offline forms:
- Batch rule actions together using the complete the following in a batch execution type because only one call is made to the server when you use offline forms. It is recommended that you have one action button and the rule for this button must contain all actions that you want to record when offline. SmartObject method actions and workflow-related methods are examples of actions that must be recorded while offline.
- You cannot use the Execute another rule action in a rule you create for offline purposes because the sub rule actions cannot be not batched with the parent rule and additional server calls are necessary.
- The system-generated When the Workflow View is being submitted rule only records the actioning of the worklist item while offline.
If you want to save new or edited data on the offline form, you must create a button and configure a rule to execute all offline actions in a batch. Remember to disable the system-generated rule when you create a new rule for offline use. Add the SmartObject method actions and the action the worklist item action to the new rule and select the then complete the following in a batch execution type as shown here:
Some scenarios and controls are not supported in offline forms. This includes but is not limited to:
- Offline forms support client-side validation, such as required fields or regular expression validation patterns. However, any validation that requires server calls, such as looking up data in a SmartObject, do not function offline.
When you use the K2 Mobile App, the K2 API web service and SmartForms Runtime site must be accessible from the mobile device.
- If the SmartForms Runtime site requires a Virtual Private Network (VPN) connection, the device must be connected to the VPN before the form is cached offline. Once the form is cached, you can open and action the form without a VPN connection. In this scenario the form submission is directed to the Outbox and syncs when the device reconnects.
- When you open a subview or subform through rules it is not available offline.
- The Content control is not available offline, see Control Support for Offline Forms for more information.
- Paging is not available offline.
- Offline forms may not be available in all versions of K2 Mobile. Check the documentation for your version of the applicable Mobile Application to verify whether offline forms are available on your mobile operating system.
- If you want to use a workflow-related form offline, you must enable the Offline Availability form property.