debuggingpowerappspowerapps-canvaspowerapps-formulapower-platform

Power apps cannot use barcode scanner function


I have tried using barcode scanner in power apps to store barcodes in a collection. I used this following formula onScan

Collect(colBarcodes,Self.Barcodes)

Then, I show the collection in a gallery by defining "colBarcodes" in the gallery item and set a formula to a text label in the gallery

Thisitem.Value

It used to be worked (I start implementing this code since last year) and work correctly until now (21/02/2025) that I found the barcode scanner didn't work anymore. It show that Self.Barcodes is error from

JSON paring error. expected 'object' but got 'array'

Also, the gallery didn't display barcode correctly. It show error that

Name isn't valid. 'Value' isn't recognized

I try using the following formula onScan

Collect(colBarcodes,{Barcode : BarcodeReader1.Barcodes})

and set the text label formula

Thisitem.Barcode

But, it still didn't work. I need it to be able to collect barcodes and show in a gallery once again. Can someone help me solve this issue please ToT


Solution

  • I had recently observed that the legacy barcode scanner in PA is disabled by default. You may want to check this in the app settings first.

    enter image description here

    If the feature was working fine earlier and stopped working recently, then you may want to try reverting the "Authoring version" of the app. This would only be a temporary solution and you may need to introduce the newer barcode scanner component.

    enter image description here

    Finally, if you want to see what's happening with your collection "colBarcodes", view it by going to ...

    enter image description here

    It seems that the barcode scanner is returning a table.

    Barcodes – Output property that contains a table of the barcodes scanned with two columns: Value, and Type. Value is the text value of the code that was scanned, while Type is the type of the code that was scanned. [Ref]

    enter image description here

    So you may need to do something like this.

    Collect(colBarcodes, {Barcode : First(Self.Barcodes).Value})