Preparing for Data with a Pre-Scan Action

A pre-scan action allows you to execute any JavaScript on a page before the scan data is pushed into an input field. You could trigger a button click, navigate within the page, or switch focus to a field designed to accept the scan data; as this sample demonstrates.

The example application has been configured to execute some JavaScript to locate, select, and clear a text box before the scanned data is inserted using the keyboard wedge capability. You can view the JavaScript by long pressing and editing the app within Surfy Industrial.

You can view the JavaScript in the configuration settings for the Example application, which is located on the launchpad. Within the launchpad long press the Example app's tile and select the edit icon.

Please note that pre-scan JavaScript is only enabled when the keyboard wedge is enabled.

Press the barcode reader hardware button on your device and scan a barcode. The barcode information should be displayed in the second text box below.

Understanding Pre-Scan Actions

This page contains three input fields, as shown:

<input id="field1" type="text"/>

<input id="preScanExampleField2" type="text"/>

<input id="field3" type="text"/>

The example application is configured with the following pre-scan JavaScript:

var field = document.getElementById('preScanExampleField2');
if (field != null) {
field.innerText = '';

When the device scans a barcode, the JavaScript is executed on the page. This occurrs before sending the barcode to the page (if keyboard wedge is enabled).

TIP: You can combine a pre-scan action with a post-scan action to change and restore focus to an active page element.