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 lives 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 URLs from Barcode or QR code.

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

In this app we have used two scanners:

  • To get Scan information from the Barcode or QR code.
  • Open the URL that is present in the Barcode or QR code.

1. Now select the “Barcode Scanner” media from the list of media as shown below screenshot:

2. After the Barcode Scanner gets added to the screen, use the formula on the “onScan” property of the Barcode Scanner to get the value of the Barcode or QR code while scanning the code. Then using the “Set” method of the Barcode Scanner scanned value; set in the “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.

Building custom Business Apps that connect to your data stored in 3rd party platforms, cloud or on-premises data sources can streamline complex business operations.

Our experts at Inogic- Professional Services simplify the process.
Write to us at crm@inogic.com for experienced and trusted assistance!

59 thoughts on “Working with Barcode Scanner in PowerApps

  1. yenny gutierrez

    HOW CAN I STORE THE SCANNED INFORMATION IN A DATABASE AS EXCEL?

    1. inogic

      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!

      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 ?

        1. Inogic

          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!

  2. 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?

    1. Inogic

      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.

      1. Asyraf

        Hi im new in powerapps. can you show how to collect the scanned locally. Thank you

        1. Asyraf

          Hi im new in powerapps. can you show how to collect the scanned locally. Thank you.
          *please reply on this comment. previous comment got wrong email address

  3. 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:;

    1. Inogic

      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!

  4. 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.

    1. Inogic

      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!

  5. 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

    1. Inogic

      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!

  6. 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.

    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

      1. Inogic

        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!

  7. 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

    1. Inogic

      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.

  8. 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 ?

    1. Inogic

      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.

  9. 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

    1. Inogic

      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!

  10. 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

    1. Inogic

      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!

  11. Larry Kiang

    Is there a way to enable barcode scanner without having to press the button? We want it alway on.

    1. Inogic

      The barcode scanner control has same accessibility as a button control because it’s the button that launches the scan.

      Due to this we cannot launch the scan without pressing the barcode scanner control which is indirectly a button control.

      Hope this helps.

      Thanks!

  12. Messilois

    Why the barcode scanner only can scan one time?
    The second time it cannot work.
    Close the app and open again.
    The scan can work.
    Which mean only one scan.
    Please help

    1. Inogic

      You need to press the barcode button again to scan the different barcodes.

      If you are filtering any records after the barcode is scanned and navigating to a different screen to show the details of the record then you need to add back icon and ‘onSelect’ property of this icon; add Back() function as shown below:

      Barcode-Scanner

      Now on clicking the icon, you will be navigated to the main screen where Barcode (i.e. the button) is placed so that you can re-click the barcode button.

      Let us know if we are missing something.

      Thanks!

  13. Ross

    Hi,
    I’m relatively new to the PowerApps and have used your guidance to produce a simple scan In and out feature for employees where they have a QR code on their ID pass, so many thanks for this.

    Similar question to Larry Kiang above in relation to the always on function…
    Due to COVID I want to limit the amount of people touching the Scan button of a busy office, so was wondering if there was any command to loop the scanner function after the OnScan command completes successfully…
    Eg. Someone will press the scan button once to get the barcode scanner function live.
    Once the Scan has been completed, it will go to a success page then loop back to the scanner again for the next barcode?

    Thanks

    1. Inogic

      We cannot loop ‘onScan’ property of the Barcode Control because this control is indirectly a button control and on the press of this button scan is launched and users can scan any barcode.

      So we cannot launch the scan without pressing the barcode scanner control which is indirectly a button control.

      Hope this helps.

      Thanks!

  14. Andy

    If I had a QR Code that scanned several pieces of information at once, how could I separate them into different fields.

    I.e. Scan a QR Code and the Value returns “City, Building, Location, Asset#, Model, Serial”

  15. Maddy

    I’m using power app to collect SN’s via scan along with an audit field populated. These will get submitted to the list, but then may need to be edited in the App – when I’ve gone back in to edit, the SN disappears, how can I get that to remain on edit only without having to re-scan?

    1. Inogic

      Add one text box control or use your existing SN textbox control on the Edit form and bind Scanned SN value in text box control as given in below screenshot so you will see scanned value when you come back to the edit form.

      Hope this helps.

      Thanks!

  16. Karl

    Is there an way that the app can record the geographical location (Like an google maps pin) when you scan the item and also post it to the excel sheet?

    1. Inogic

      Hi,

      Using Location signals in PowerApps you can store geocoordinates(Latitude/Longitude) on Scan of Barcode Scanner in Excel Sheet.

      Add Latitude and Longitude columns in the excel sheet then add the below formula on ‘onScan ‘properties of Barcode Scanner

      Patch(
      ScanInfo,
      Defaults(ScanInfo),
      {
      ScanData: BarcodeScanner1.Value,
      When: Now(),
      Latitude: Location.Latitude,
      Longitude: Location.Longitude
      }
      )

      Hope this helps,
      Thanks!

  17. Kwame

    Hi,
    I am using two scanner on Edit form; one scanner for location and the second one for catalog number. When I am editing, the scanner text box shows as empty. I will please a formula to filled the text label which values are already available and for new form make the label blank. Thank you

    1. Inogic

      Hi,

      • Add below formula on “onScan” property of Barcode Scanner to navigate the edit screen and set the variable “scanValue” as value obtained after scanning the barcode scanner.

      • To make the Label blank when the Edit form type is New, add below formula on new button to make the scanValue variable as Blank.

      • To display the scan value from the barcode you can add below formula on the Text Property of the Label. The formula will be display the scanvalue from the barcode scanner.

      Hope this helps!
      Thanks

  18. Farid

    Hi,
    I wonder how to get list data from sharepoint after get value in powerapp?
    Ex;
    Sharepoint List: (named as : ShopItem)
    ID=12345, ItemName=Pen
    ID=67890, itemName=Pencil

    So, once I scan the QR Code & get the value is 12345
    the other textinput will appear as ‘Pen’

    *Consider I know how to add data source to powerapp
    Thank you.

    1. Inogic

      Hi,

      Use the below formula on “onScan” property of Barcode Scanner to get itemName value related to scan ID value and set it in the textbox.

      Set(itemNametxt, LookUp(ShopItem,itemID= BarcodeScanner1.Value).ItemName)

      Using lookup function barcode value compare with Shopitem itemID then return itemName from Shopitem table. ItemName value set in itemNametxt variable.Then use itemNametxt variable in “Default” property of Textinput1.

      Hope this will resolve your issue!
      Thanks

      1. Edin Muderizovic

        Hi Guys,
        I do not know if Farid has solved his problem, but I was able to solve mine :-). The same issue only with CDS, Instead of SHP List and itemNames I was taken Entities and Fields – and it works ! I broke my head for days and then I found Farids problem. changed SHP list and item Names to Entities and Fields and after days and days I got Room Number Name ( another field) after Scanning of Room Bar Code. Now I have to do the same with Fixed Assets and thats it ! Problem solved ! Thank You sooooooo much ! BR Edin

        1. Inogic

          Glad to hear the solution worked for you Edin!

          Let us know if you need any further assistance on the same.

          Thanks for interacting!

  19. Darren

    Hi Inogic

    Thank you so much for this post i have made app to scan printer toner cartridges in and out of an sharepoint list and to display the info on the screen when scanned.

    I am having trouble setting up a formula to give me the total in stock when i scan the barcode.

    any help would be helpful

    Darren

    1. Inogic

      Hi Darren,

      On the Barcode “OnScan” Property we have added the below formula to filter the SharePoint list when the barcode is scanned:

      Now to calculate the total you can use “Sum” function in power apps as show in below screenshot:

      You can refer to the below link for more information regarding the Sum function

      https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-aggregates

      Let us know if you have any queries related to the same.

      Hope this helps!

  20. Esh

    Hi,
    I have a trouble when setting up formula for Barcode.I use a form to collect input and to send those data to data base. Currently I am using manual data input to form.But I want to use Barcode system to get those inputs and send to database.
    These are the inputs, Batch No.
    Supervisor name
    No.of layers
    No.of Pieces
    This would be very helpful for me to continue my powerapp.Thank You.

    1. Inogic

      Hi Esh,

      You can use the “Split” function to get the result after the Barcode is scanned and you can create the record in the data source using the Patch function.

      Now assuming after scanning the barcode the value will return to “AB001;Merry Rose;3;4”, you can add the below formula on the “onScan” Property of Barcode where we have created a record in Product entity in Dynamics365 CE using Patch function.


      Patch(
      Products,
      {
      'Product ID': First(
      Split(
      BarcodeScanner1.Value,
      ";"
      )
      ).Result,
      'Supervisor name': Last(
      FirstN(
      Split(
      BarcodeScanner1.Value,
      ";"
      ),
      2
      )
      ).Result,
      'No.of layers': Value(
      Last(
      FirstN(
      Split(
      BarcodeScanner1.Value,
      ";"
      ),
      3
      )
      ).Result
      ),
      'No.of Pieces': Value(
      Last(
      FirstN(
      Split(
      BarcodeScanner1.Value,
      ";"
      ),
      4
      )
      ).Result
      )
      }
      )

      In the above formula, we have split the barcode value with “;” using the Split function and mapped the fields of the Product entity by the result.

      Hope this helps!
      Thanks

  21. Tom Moore

    Can this be used to grab multiple fields store in the barcode on a Driver License?

    I am in Law Enforcement and we have to grab information in the field on most calls. Let’s say an accident. I would like to add to my application where I am able to scan a DL / ID and get all the information contained therein into my list. (LNAME, FNAME, MNAME, OLN,DOB, ADDRESS, HGT, WGT, EYES, etc.)

  22. Alena

    Hi there. Is there a way to use a portable Bluetooth scanner instead of mobile camera for scanning in Power Apps?
    Thanks!

  23. CHARLENE

    Hello,
    Is there any we can let the scan value been edit?
    Which means they can either choose to scan the code or manually type the code?

    1. Inogic

      Hi Charlene,

      Yes, you can either choose to scan the code or enter the code in the textbox.

      For onScan property of the BarcodeScanner set value in the variable as shown in the below screenshot:

      Now set the Default Value of the Textbox as scanValue variable as shown in the below screenshot:

      User can edit the Barcode Value or enter the code manually from the Textbox and further use this Textbox Value in the app.

      Hope this helps
      Thanks!

        1. Inogic

          Hi,

          We looked into the Patch function screenshot you attached and it seems that you are using Online Excel to store the Barcode data, Who, When data as well. So, once configuring the OnScan Event on Scan Button in the Power App as mentioned in the attached screenshot, we can publish the changes by navigating to File and clicking on Publish. Please refer to the below screenshot for the same.

          Barcode Scanner

          Once changes are published, the user can log in to the Power App with desired credentials, which will display all Canvas apps created in the CRM.

          Barcode Scanner

          Now, scan the Barcodes from the Canvas app using the Scan button as shown in the below screenshot.

          Barcode Scanner

          Due to Patch Function on OnScan Event on Scan button, data will be captured in the Online Excel as shown in the below screenshot.

          Barcode Scanner

          Hope this helps.

          Thanks!

  24. Marie

    Hello!
    With the barcode scanner I can scan a QR and when reading it go to the record that belongs to it to edit any field?

    Thank you.

    1. Inogic

      Yes, you can scan and open the URL embedded in the QR code using the Barcode Scanner in Power Apps.

      So, let’s say you want to open any record in Dynamics and you are already logged-in, then it will directly open the record. But if you are not logged-in to Dynamics then you need to first login and then it will take you through the record where you can edit any fields.

      Hope this helps.

      Thanks!

Comments are closed.