How To: Building Forms for Mobile
The following topic discusses how to create a form that is configured to be used in the K2 Workspace app. The form configuration contains various mobile options such as the use of the barcode scanner control, responsive themes, application forms, and offline availability.
Runtime Example
Scenario
The following scenario includes the creation of a Returns form that allows customers who have purchased a product and wish to return it. The return is done using a form that is available in the K2 Workspace app.
Steps
- Open K2 Designer and create a SmartObject called Returns with the following properties.
Returns SMO Properties Type Key Required Unique ID Autonumber Yes No Yes Name Text No No No Surname Text No No No Contact Number Number No No No Contact Email Text No No No Product Name Text No No No Product Barcode Number No No No Purchase Date Date No No No Return Option Multivalue No No No - Generate an Item View for the Returns SmartObject.
- Open the Returns item view, and disable the Visible option for the ID label and text box controls.
-
Remove the Create, Delete, and Load buttons. Select Remove all dependencies when deleting the buttons.
- Move the Save button under the Return Option.
-
Rename the Save button to Submit.
- Reorganize the view as shown here:
- Select the Contact Number text box control and click the Styles ellipse ... button.
- Select Special from the Format tab then select Phone Number. Click OK.
- Select the Return Option Check Box List control and click the Change Control option.
- On the Change Control: Return Option Check Box List page, select Choice and click OK.
- Click the Typeellipse ... in the Data Source section of the Return Option Choice control.
- On the Configure Data Source page, select the Use a static list of values in the control option, and click the ellipse ... button.
- On the Fixed List Configuration page, click Add.
- Add the Refund, Exchange, and Store Credit on the Fixed List Configuration page. Click OK and OK again.
- Click Finish and Check In the Returns Item View.
-
Drag the Barcode control from the Input section in the Toolbox tab on to the view.
- Drag a Button control from the Action section in the Toolbox tab under Product Barcode text box control and rename the button to Scan.
- Go to the Rules tab and click Add Rule.
-
Add a When a control on the View raises and event event. Select Barcode on the select control option and Initialized on the select event option.
- Next, click the Conditions tab and add the an advanced condition is true condition. Click an advanced condition option.
-
On the Rule Designer page, click Add. Drag the Is Supported option from the Controls > Barcode > Detail section from the Context Browser to the Left option.
- Configure the Operator option to Equals and the Right option enter false. Click OK.
-
Click on the Actions tab and add the Show a message action. Click configure.
-
On the Show a Message to the User page, configure the Title, Heading and Body fields as shown below. Click OK and OK again.
- Click Add Rule.
-
Add a When a control on the View raises an event event. Click the select control option and select the Scan Button.
-
Click on the Conditions tab and add the an advanced condition is true condition. Click an advanced condition option.
-
On the Rule Designer page click Add. Drag the Is Supported option from the Controls > Barcode > Detail section from the Context Browser to the Left option.
-
Configure the Operator option to Equals and the Right option enter true. Click OK.
-
Click on the Actions tab and add a Execute a control's method action.
-
Click on the select control option and select Barcode. No configuration is required for the method. Click OK.
-
Click Add Rule.
-
Add a When a control on the View raises an event event, select Barcode on the select control option and Changed on the select event option.
-
Click the Actions tab and add the Transfer data action. Click configure.
-
Drag the Value option from the context browser (Returns > Controls > Barcode > BarCode) to the Product Barcode Text Box field. Click OK and OK again.
- The Barcode control is now configured to capture the item's barcode on the Returns view.
- Generate a form based on the Returns Item View.
- Rename the form to Returns, select Save and edit the Form, and click OK.
- Next, select a responsive theme from the Theme option in the Appearance section. The available responsive themes are Blue Void, Grey Void and Lithium. The Lithium theme is selected.
- Add a title to the form called Returns Form.
- Expand the Advanced option on the Properties tab and select the Applications Form check box. This enables the Returns form to be accessible in the Forms section of the K2 Workspace app. For more information see Application Forms.
- Expand the Advanced option on the Properties tab and select the Offline Availability check box. This enables the Returns form to be opened and actioned in the K2 Workspace app when the app is offline. For more information see Offline Availability.
- Click Finish and check in the Returns form.
The Returns form is available in the K2 Workspace app and can used to capture data of the customer’s return. Note that the form up to this point only stores the captured data via the Returns SmartObject. You can extend this form to include an approval step within a workflow, but that is beyond the scope of this article. To learn how to associate a form with a workflow see the Start a Workflow with a Form topic for more information.