A common scenario that occurs in mobile business is the need to scan a bar code to look up information about the item the bar code is affixed to.
Effectively one wants a Form that should capture the bar code and retrieve a row from Data Source.
The way to do this is to use a Choices field along with a Data Source.
Scanning Barcodes Into a Choices Field
First of all, the Data Source needs to contain the various pieces of information for each bar coded item you expect to scan for. For example, lets call it the "Equipment" data source, where it might look something like:
|BARCODE||EQUIPMENT NAME||CONTACT PERSON||LAST SERVICED|
|123456||Premier Chair||John Smith||10/28/2018|
|654321||Standard Table||Jane Doe||7/15/2009|
The first column in your Data Source MUST contain the actual barcode values - i.e. the number or text that will be scanned in by the app.
With retail barcodes, the numbers are usually printed under the barcode lines.
Now in your Form design, you would add a Choices field with:
- Data name of say "equipmentChoice"
- Data Source to be the "Equipment" one set up previously above
- Tick the "Allow Barcode Lookup" option
Save your design, and hit the TEST button to put the Form into Test mode for you to try out. Once in Test mode, every time you save changes to the Form design, you will be able to test these on the device without having to Publish each time.
Next, run the Form on your device, first waiting for the "Sync Complete" message to confirm the new design has been downloaded.
In the Form, you should notice that there is a Barcode button on the "equipmentChoice" Choices field. Hit the button and scan a barcode with the device camera. Assuming the code matches one of the rows in your Equipment data source, the app should display that row as selected.
Populating Other Fields Based On A Barcode Scan
In terms of populating other fields based on the row selected in your "equipmentChoice" field, this is done back in the Form designer.
- Go back to the designer and add a couple more fields below your "equipmentChoice" field. (ex. a Text field for the Equipment Name, another Text for Contact Name, and a Date Only field for the Last Serviced.)
- Now on each of these fields, scroll down the list of properties on the right hand side until you see the "Bind To Data Source Column" option.
- On each field, choose the Equipment data source and then choose the relevant column to match the field.
- If you save your design and go back to the app, first make sure to force a synchronization to receive the design change. You can do this via "Check for Updates" button on the Settings screen of the app, or by simply putting the app into the background and bringing it back to the foreground via your device multi-tasking.
- Once you see the "Sync Complete" message, open up a new entry for your Form and repeat the steps to scan a barcode and get a selected row.
- This time you should see that once the row is selected in the "equipmentChoice" field, the other fields below are populated too