Preventing Double Barcode Scans

I have a text entry component that I have set to remain in focus at all times. This screen is dedicated to barcode scanning. On the propertyChange event, I have it read the text input, parse it, and write it to a tag and insert into a db table. Each scan compares the input text to the tag written to previously. If they are the same, it is supposed to reject the scan and do nothing. Every now and then a double scan still gets through. It seems that the employee scans it and may not see it populate the table, showing the scan history, immediately so they scan it again to make sure it takes. Every time I try to recreate a double scan it never works, I always get just one scan input. Am I missing something, is there a better way to do this? The basic code works like this,

if event.PropertyName == 'text':
        input = event.source.text
        lastScan = system.tag.read('compare').value
        if input != lastScan:
                insert into db
                write to compare tag

It's possible that there's a race condition between the property change event firing on your change script and the property change firing on the component itself. Try input = event.newValue instead of reading the component's property.

1 Like

I changed the code like you suggested and everything seems to work fine. I will keep monitoring it and see if it remedies the double scan. Thanks