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 users to open forms and action tasks in the K2 Workspace (Mobile) apps when they are not connected to the K2 server. When the K2 Workspace (Mobile) app is connected again, the forms are actioned and submitted. In addition, you can configure certain list controls to cache the data which is downloaded when the form initializes. This is especially useful when you need data in controls (such as drop-down lists and picker controls) to be available while the device is offline.
If you do not enable the Offline Availability form property, the form is only available when the K2 Workspace (Mobile) app is online.
See the following resources for more information:
- See How To: Enable Offline Availability on a Form for information about turning any form into an offline form for use in the K2 Workspace (Mobile) app when it's offline.
- See How To: Configure Forms with Draft Functionality for information about configuring an Application Form to be saved as drafts on mobile devices for later completion.
- See Configure Mode Conditions for information about using Mode conditions in rules to create your own business logic and perform actions such as showing a message when people open the view or form that is offline.
The following scenario uses a workflow form as an example. Follow the steps to create an offline form using K2 Designer:
- Design a form and 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 the K2 Workspace app.
- 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.
- If necessary, edit the rules that execute when the form is submitted (for example 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 Workspace (Mobile) app.
- Open the form in the K2 Workspace (Mobile) app. Note that you have to open the form at least once before you go offline, to allow any initialization rules to execute and populate the form.
- Disable network connectivity for your device (e.g. set the device to "airplane mode"), and notice that you can still open and action the form.
If you have no internet connection on your mobile device or if the K2 Workspace (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 the K2 Workspace (Mobile) app 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 caching 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.
- When configuring rules for offline forms, you cannot use the Execute another rule action because the sub rule actions cannot be batched.
- 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 Workspace (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 the K2 Mobile and K2 Workspace (Mobile) apps. 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.
- When you submit a form with the When the Form is submitting rule configured, while offline, no Send to Outbox notification displays. If your form has the also execute the Submitting Form method rule configured the Send to Outbox notification displays
- Offline forms and caching:
- SmartForms caching starts when the app loads. This does not immediately include Task caching. The caching is applied according to the details described in Client side filtering.
- If a workflow task contains a form and the form is marked for offline availability, the task shows a light green download icon on the mobile device, indicating the form can be downloaded for offline use. The light green color shows that the form has not been downloaded yet.
- When you open a task containing a form that is marked for offline availability, the form starts to download. Once the download is complete, the icon changes to a darker green.
- If the device goes offline before the download is complete, the form on the task is not available and an offline message is shown when you try to access the form.
- If the device goes offline after the download, you can view and submit the form, and action the task. When you action the task, you can select to send it to the Outbox. When the mobile device is online, all offline submissions are processed.