Working with Barcode Scanner in PowerApps

By | May 22, 2019

Introduction:

Barcodes provide a convenient way to pass information from the real world to your app. We see the use of barcode and barcode scanners in our everyday life i.e. while shopping, renting a car, attending major events, flying and so on. They’re in our social media apps and on store windows.

Using Barcode Scanner in Power Apps we can get data or can open URL from Barcode or QR code.

Let’s just start exploring this media by simply creating a Barcode Scanner App to get data and open URL from Barcodes or QR code.

In this app we have used two scanners:

  • To get Scan information from Barcode or QR code.
  • Open URL that is present in Barcode or QR code.
  1. Now select the “Barcode Scanner” media from the list of media as shown in below screenshot:
  2. After Barcode Scanner gets added in screen, use the formula on “onScan” property of Barcode Scanner to get the value of Barcode or QR code while scanning code. Then using “Set” method of Barcode Scanner scanned value; set in “scanvalue” variable.

Set(scanValue,BarcodeScanner1.Value)

  1. Select “Label” and set “text” property of label as “Scan Result:”

  1. Select another “label” to display the result of Barcode Scanner. Then set “Text” property value as “scanvalue” variable that contains scan value as shown below:

  1. Now add another scanner on the screen to open a link that is present in the code. Now set “Text” property of BarcodeScanner2 as “Scan and Go”:
  2. Now set formula on “onScan” property as “Launch(BarcodeScanner2.Value)” to open URL that is set in the barcode or in QR code. After this save the app.
  3. Now open an app in mobile to scan barcode or QR code. Initially the app will ask for camera permission because one can scan barcode or QR code by using mobile camera. Next click on “Allow”.
  4. After clicking on “Scan” button mobile camera will scan barcode or QR code as shown below:

  1. Scan information is displayed on mobile.
  2. To open particular URL Click on “Scan and Go” Button. In the below example, we have used QR code related YouTude video. After scanning, the YouTube app will open in mobile and the video will start playing.

Conclusion: Using Barcode Scanner media in power apps we can easily scan Barcode or QR code.

23 thoughts on “Working with Barcode Scanner in PowerApps

    1. inogic Post author

      Yes, you can store scanned information in database as Excel. For this, you need to follow the steps given below:

      1. Create a table(ScanInfo) in Excel with three columns.
      ScanData: Scan data from Barcode or QR code.
      Who: User who use this App.
      When: Date and Time when Barcode or QR code get scanned.

      Barcode or QR Code

      2. Create a Canvas App and connect your Excel sheet that is stored in cloud-storage account. You can refer this article to connect Excel to PowerApps.
      3. Now select ‘Barcode Scanner’ media from the list of media. Use the below formula on ‘onScan’ property of Barcode Scanner to get data of Barcode or QR code while scanning code and store that data in Excel table(ScanInfo) to respective columns(ScanData, Who, When) using Patch method.
      Patch(
      ScanInfo,
      Defaults(ScanInfo),
      {
      ScanData: BarcodeScanner1.Value,
      Who: User().FullName,
      When: Now()
      })

      Barcode or QR Code

      By using above formula, you can create scan data record in data source.

      Hope this will help you.

      Thanks!

      Reply
      1. dave

        Thanks ! This helped me review an area i was stuck. Though i was really looking to add a few more fields with the scaner input. I had a few dropdown choices that they can choose from. Then hit SCAN and it will send all that to excel. Any suggestion how to take other data from drop down ?

        Reply
        1. Inogic Post author

          You can send dropdown selected value also to excel on the scan of the barcode. Write below patch function on the “OnScan” property of the Scanner media to send/create the data in Excel table(ScanInfo) to respective columns(ScanData, ItemType).

          • ScanData: store scan data from Barcode or QR code.
          • ItemType: store dropdown selected value

          Barcode

          Hope this will help you.

          Thanks!

          Reply
  1. Alfredo Brioli

    Is there a way to have multiple scans?
    We are sometimes packaging multiple products in one container and I want to scan all of those products and collect them on one row in my excel spreadsheet.

    It looks like you can’t increment the ScanValue variable, is there another way?

    Reply
    1. Inogic Post author

      The Patch() can be used to add as well as update an existing record. You will need to store the scans in a collection locally. And then on final submit store all the bardcode scans as a comma separated value in the excel.

      if the records will not be scanned at the same time, you will need to maintain a unique id for each record stored in excel and use the id to update the record for future scan values.

      Reply
  2. Jason Walker

    Is it possible to use a barcode scanner that applies value to a label. Then use that label value to send to a SharePoint button to send to SharePoint?

    I set it up like this:. ::Button:: (to use to send to SharePoint after verification of correct barcode scanner with scanner and then sent value to label)
    ::Label:: (just shows barcode scanner value)
    ::Barcode scanner:;

    Reply
    1. Inogic Post author

      You can send the scanned value to SharePoint List. Here, you can see I have added a button which scans the barcode and sends it to the SharePoint List.

      For OnScan property of button, I have written the below patch function to send/create data in SharePoint.

      barcode-scanner

      ‘TestingList’ is the list name of SharePoint. To see this SharePoint List, you need to add SharePoint list as a datasource in your app.

      Barcode Scanner

      ‘Title’ is the column of list and ‘BarcodeScanner1’ is the BarcodeScanner control name to read scanned data.

      Hope this helps.

      Thanks!

      Reply
  3. Brad Miller

    I tried using the Patch function to write the data from my BarcodeScanner1 input to my Excel data source:
    My data is in Table1
    The field i want to populate with the Barcode scan is ProductionID

    Patch(
    Table1,
    Defaults(Table1),
    {ProductionID: BarcodeScanner1.Value})

    Is this the right syntax? It didn’t work for me.

    Reply
    1. Inogic Post author

      Yes, you used the right syntax. You should also ensure that just your PowerApps is properly connected to the Excel sheet.
      Please refer this article to connect Excel to PowerApps.
      And let us know where your Excel sheet is stored so that we can help you with it.

      Thanks!

      Reply
  4. dave

    Thanks so much for this ! One more question is i noticed when i put the Gallery view in it shows the Scan information in oldest to newst and not newest on top. I couldnt find where to change this

    Reply
    1. Inogic Post author

      Follow the steps given below to show the latest scan value at top of gallery view.

      • To sort data add When (Contain Date and time) column to your excel sheet and in patch method to store date and time when Barcode or QR code gets scanned as shown below:

      Barcode

      • If you use Gallery control then write below SortByColumns function on the ‘Items’ property of the same to sort data using ‘when’ column. Please refer to this article to get more information about the SortByColumns function.

      Barcode

      • If you use BrowseGallery then write below SortByColumns function on the ‘Items’ property of the same to sort data using ‘when’ column.

      Barcode

      Hope this will help you.

      Thanks!

      Reply
  5. dave

    Thanks again for all the help ! I have one more question. The “form” i have created has many drop down choices that the person can choose then it adds that info with the Scanned info into Sharepoint. This works 100% . Very happy I know it sounds simple but I dont have much experience with this tool.

    Though one thing I am trying to do is when after the scan or when the patch command adds the info to SharePoint and returns back to the form. Is there a way to reset the drop down choices to the default value and not the last chosen value.

    Reply
    1. dave

      I am able to add “Reset” button as that allows the onSelect option though i would like that to be intergrated into one button push with the scan

      Reply
      1. Inogic Post author

        Write below reset method with patch method on the “OnScan” property of the Scanner media to reset dropdown values after scanning of barcode done. Please refer to this article to get more information about the “Reset” method.

        Barcode

        Hope this will help you.

        Thanks!

        Reply
  6. eladio

    it is possible to connect a bar reader using the powerapps interface and not using the camera and if possible, how to do the steps for its configuration

    Thank you very much, greetings from Chile

    Reply
    1. Inogic Post author

      No, it’s not possible to connect the barcode reader device to PowerApps. To scan the barcode from PowerApps you need to use ‘Barcode Scanner’ media control.

      Reply
  7. dave

    One more question. So i created “form” that has few options to scan items

    EX: Tracking # , Asset # etc .

    It will display all the information of each scan . Then some drop down box for choices.

    After all this done I am using a patch command to send it to sharepoint and reset the options choosen. This all works but if the person wants redo the form again it wont let you submit twice. Any suggestions ?

    Reply
    1. Inogic Post author

      As per my understanding, on ‘onScan’ properties you wrote a patch and reset method to send data to SharePoint and reset option set .First time it worked but the second time it did not. We checked the same issue at our end but was not able to replicate it. Did you, by chance add any other code on ‘onScan’ properties?

      Please provide more information about the same so that we are able to replicate the same issue at our end.

      Reply
  8. Robyn

    Thanks for the information…really helpful. Is there a way I can get the scan to ignore the first character of the scan?

    Thanks

    Reply
    1. Inogic Post author

      Glad to hear that the blog was helpful to you!

      Yes, we can ignore the first character of scan value using the ‘Right’ and ‘Len’ functions. Please refer the below formula:
      Right(scanValue,Len(scanValue)-1)

      The ‘Right’ function returns the ending characters of a string and ‘Len’ function returns the total length of the string. So considering the length of the ‘scanValue’ variable, we have -1 the length and removed the first character taking the Right characters of ‘scanValue’ variable.

      Please see the screenshot below for your reference:

      scanvalue

      Hope this helps!

      Reply
  9. James Wood

    Hi this is excellent and has been of great help to me in setting up an inventory system, is there a way that when I scan a barcode it can go straight to a details screen showing the record values associated with the retrieved barcode value? Many thanks

    Reply
    1. Inogic Post author

      Glad to hear the blog was helpful to you!

      Yes, you can filter the detail screen with the barcode value using the “Filter” function in PowerApps.

      Here in below example we are showing Account record detail associated with retrieved barcode value. Please follow the below steps to show the records values associated with the retrieved barcode value:

      1. We have added Home screen which contains button “Scan and Go”. On the onScan property of the Barcode add the below formula:
      Launch(BarcodeScanner1.Value);Navigate(DetailScreen, ScreenTransition.Fade, { scanvalue: BarcodeScanner1.Value } )

      barcode-scanner

      The above formula will launch the Barcode and navigate to the detail screen. The navigate function will pass the Barcode Scan Value in a “scanValue” variable to the Detail Screen.

      2. Update the below formula on Item property of detail screen:
      First(Filter([@Accounts],’Account Number’= scanvalue))

      In above formula ,the filter function will retrieve the account record where field “Account Number” is equal to value obtain after scanning the barcode.

      barcode scanner

      Hope this helps.

      Thanks!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *