Barcode
The Barcode control allows you to capture barcodes in a form when using the K2 Mobile app. You must configure this control when you're designing the form and configure rules to handle the events and data captured using the control. For general information about barcodes, see https://en.wikipedia.org/wiki/Barcode
The control is not a display control and is not shown at runtime on the form. When using the form, you'll click a button or take some other action to scan a barcode, and the resulting data is transferred to a text box or similar control. At design time, you see a visual representation of the control that you can configure.
Follow the steps below to configure a scenario where the control is used on a form.
- Create a Stock Control SmartObject to act as a database containing product information and associated barcodes.
- Auto-generate an Item view and form from the SmartObject.
- Edit the Item view and drag the Barcode control onto the canvas. The control is available in the Input section of the Toolbox.
- Add and configure the following controls:
- a Button called Scan
- a Label called Bar Code Number
- a Text Box
- Navigate to the rules and add the following rule:
- Configure the condition as follows. The condition detects if the control is supported.
- A message is shown explaining that the barcode control is not supported on the device:
- Finish the rule and add the next rule, when the button is clicked:
- Configure the condition as follows. In this case, if the device is supported, then the rule continues.
- No configuration is required for the Scan method
- Save the rule and add the last rule that detects if the value of the barcode control changes:
- Configure the transfer action to transfer data from the barcode control to a text box:
- Save the rules and the view.
- Check in the view.
- Edit the form and continue to the Layout page.
- Click the outline of the form to see the form properties, expand the Advanced section of the Properties, and select the Application Form property. This field is required for the form to show up on the Forms menu in K2 Mobile.
- Finish the form, then save the form to the K2 Mobile App location:
System>Application Forms
- Open K2 Mobile on a mobile device.
- Access the Forms menu.
- Open the Stock Control form.
- Capture information in the form.
- Click Scan to scan the barcode of the item, and then click Done when the item is scanned.
- Note the barcode number from the scan is now in the text box. You can alternatively save the data to a SmartObject for later use.
The control is available in the Input section of the Toolbox
Property | Description | Can be set at runtime using rules? |
---|---|---|
Detail | ||
Name | A unique identifier for the selected control. This property is required and defaults to the name of the control. | No |
Is Supported | A value indicating if the device is supported. This control is only available for use with the K2 Mobile app. It is a good idea to use a rule condition to check if the device is supported before continuing with any operations. This property can only be used to set properties of other controls. | No |
Barcode | ||
Value | The value of the barcode. You can only use this property to set properties of other controls. | No |
The control interacts with other controls through rules. When you bind properties between different controls, you can use the data to populate properties or set values in runtime. Use the following examples for when to use the control with other controls through rules:
- Set a control’s properties - You can configure the settable properties of the control with this action
- Data Transfer - You can transfer data from items listed in the context browser to the control
- Execute a control's method - You can configure the control's method using this action
The following events and methods are available on the control.
Rule events:
- When the [control] is Changed - You can execute a rule condition or action when the control is changed, for example selecting an item or transferring a value to the control
- When the [control] is Error - You can execute a rule condition or action when the control is in error
- When the [control] is Initialized - You can execute a rule condition or action when the control is initialized
- When the [control] is Not Supported - You can execute a rule condition or action when the control is not supported, for example showing a message to the user
- When the [control] is Scanned - You can execute a rule condition or action when the control is scanned
- When the [control] is Scanning - You can execute a rule condition or action when the control is scanning
Control method:
- Scan - Scans the barcode of an item
- The control is only available for use with the K2 Mobile app
- The control is not a display control
- You must configure rule events and actions to execute the control and do something with the data captured by the control