Using the Scanner object

Constructing a simple form with fields and an optional scanner object. The user will scan a barcode with several pieces of data in it. How do I extract the data in the capture handler? {{scanner1.data[0]}} extracts the whole string. Example 1,10123-60-D,0001 . I want to create three capture handlers to assign the values to each of the fields. Can't seem to figure out the correct JavaScript syntax.

Welcome to the forum!
Check out using a Listview you can then iterate through the string and get the length of it (after converting to an array and then use the Listview to contain the number of fields you need according to that length.

Hi @bhenderson , welcome,

You can split the scanned code by creating a transformer and add:

const array = {{scanner1.data[0].split(‘,’)}}
return array;

You can then acces the array items separately.

I added a transformer. The next problem is that the scan doesn't return the values on the first scan. The first scans values show on the second scan. I have Capture event handlers for each field that take the transform1.value[0] and setvalue() to the appropriate text field. It behaves like the submit action happens before the setvalue. Not sure how to fix this.