web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to scan Barcode wi...
Power Apps
Answered

How to scan Barcode with 2 Lines of GS1 barcode?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi. 

 

I've created a barcode scanning tool that scans products, shows it in the gallery, and the ability to submit it to sharepoint/email. 

 

The barcode contains, product ID,Lot number,and Expiry date (in this order) and works well when this is contained in 1 line of barcode.

However, I discovered that the smaller items have barcodes separated in 2 lines and so, the scanning tool leaves behind valuable information. 

1. Product ID on the first line

2. Lot number and Expiry date on the second line. 

 

How should I program the app to be able to populate the 2 barcode lines as 1 barcode line to populate the product information?

 

*Currently, if the Product ID does not match the Product ID in the database,  the product will not be collected in the gallery. Maybe there can be an exception if the scan before is a Product ID that is missing the 2nd line of information. 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    Hi @Anonymous ,

    You did not mention whether you could successfully scan the second line. Assuming you can (if not, there is no real answer), there are two options.

    The scanner has a property BarcodeType, normally set to Auto. I have never needed to use this, but trying different combinations may be the solution.

    The second one would be to scan each separately - on the OnScan of your Barcode control, do this

    If(
     IsBlank(vScan1),
     UpdateContext({vScan1:YourScanControlName.Value}),
     UpdateContext({vScan2:YourScanControlName.Value})
    )

    as a protection, if the first code has (for instance) a different length (16 used below), you could also do this.

    With(
     {
     vFirst:
     Len(YourScanControlName.Value)=16
     },
     If(
     IsBlank(vScan1) && vFirst, 
     UpdateContext({vScan1:YourScanControlName.Value}),
     !vFirst && !IsBlank(vScan1), 
     UpdateContext({vScan2:YourScanControlName.Value})
     )
    )

    Then have a Button with the DisplayMode

    If(
     !IsBlank(vScan2),
     Displaymode.Disabled,
     DisplayMode.Edit
    )

    then OnSelect of the Button

    UpdateContext({vScanItem, vScan1 & vScan2});
    UpdateContext({vScan1, Blank());
    UpdateContext({vScan2, Blank());
    ....Write ScanItem to your list . . . .

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    Wow, Thank you! You taught me a lot.  

     

    I'm not able to replicate your solution because my code is a little bit more complicated than I originally explained, but now learned the "With" and "UpdateContext" functions.

     

    The second barcode can be successfully scanned as well. 

     

    I'd like to hear your thought on what I have so far. 

     

    I placed a toggle on/off statement when an item is scanned. (Hidden to the user) 

    If it is off, then it scans 1 line barcodes

     

    How my app works with products with 1 line of barcode (contains all of the information, item code, lot number, expiry date in 1 line)

    Step 1: Scan the item

    Step 2: Item code portion of the barcode is matched against the item code database, and if it exists, I have a collect function and dissects the barcode information. If not, then error pops up

    Step 3: The dissected information is placed in the gallery for the user. 

     

    *This part works well

     

    For the products with 2 line of barcode. (1st line is item code, 2nd line is lot number and expiry date) 

     


    Step 1: Scan the first barcode  (Item code)


    Step 2: Item code is checked against the item code database & checks if  the length of the 1st barcode is 16 digits. If it is true, then sets toggle to true and is ready to scan the second barcode, if not then error pop up. 
    *This makes it so the first barcode is always scanned first 

    " Len(BarcodeScanner1.Value)=(16),
      UpdateContext({Scan1: BarcodeScanner1.Value}) & Set(settoggle,true), "

     

    ** I don't know if it's UpdateContext or Set to hold values 

     


    Step 3: Now the toggle is set to true, Scan the 2nd line of barcode, and just to be safe, checks if its not an item code. If it is not an item code, then it concatenates the Scan1 & 2nd Barcode value, if not then error popup

     

    Concatenate(Scan1,BarcodeScanner1.Value) ; Set(settoggle,false) 

     

    Step 4: Dissect the combined barcode value and collect it line a single barcode. 

     

     

    I don't know how to incorporate the collect function to dissect the Concatenate, however as it's Scan1 does not show up because it's 1 big function.  

     

    Hope to hear your feedback! 

     

  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    Thanks @Anonymous ,

    I have posted your progress below so I can comment against it.

    Step 1: Scan the item   Step 2: Item code portion of the barcode is matched against the item code database, and if it exists, I have a collect function and dissects the barcode information. If not, then error pops up  Step 3: The dissected information is placed in the gallery for the user.  *This part works well

    Great - I assume the dissection is what what you are mentioning at the end? You have not explained it to this point.

    For the products with 2 line of barcode. (1st line is item code, 2nd line is lot number and expiry date)  *Placed a toggle so if it is on, it's ready to scan the 2 lines of barcode,  Step 1: Scan the first barcode  (Item code)  Step 2: Item code is checked against the item code database & checks if  the length of the 1st barcode is 16 digits. If it is true, then sets toggle to true and is ready to scan the second barcode, if not then error pop up. *This makes it so the first barcode is always scanned first 
     Len(BarcodeScanner1.Value)=(16),
    UpdateContext({Scan1: BarcodeScanner1.Value}) & Set(settoggle,true),

    Good idea

    ** I don't know if it's UpdateContext or Set to hold values 

    You can use Global Variable Set() if you want - a Context Variable only exists on the Screen and not when you navigate off. Here is the Microsoft document for you to read.

    Step 3: Now the toggle is set to true, Scan the 2nd line of barcode, and just to be safe, checks if its not an item code. If it is not an item code, then it concatenates the Scan1 & 2nd Barcode value, if not then error popup 

    Concatenate(Scan1,BarcodeScanner1.Value) ; Set(settoggle,false) 

    Doing good so far - where are you putting this value (in a Variable?). If so - I will use Set()

    Set(
     vCombined,
     Scan1 & BarcodeScanner1.Value
    )

    Step 4: Dissect the combined barcode value and collect it line a single barcode. 

    I don't know how to incorporate the collect function to dissect the Concatenate, however as it's Scan1 does not show up because it's 1 big function.  

    You have the combined code in the Variable above - what do you refer to with Dissect?

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    Hi @Anonymous ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    Thanks for your help.

    Dissect meant that I was using Collect() and putting the barcode information into it's proper columns for analysis 

     

    So I figured it out. Here are the steps.

     

    Item is scanned and has a True or False Umbrella. 

    Begins with the scanner set to True, and falls into the True Umbrella. 

     

    True umbrella.

    1. IF statement to check if the barcode is a real item or not.

    1. If it is real item
      1. Checks if it is only 16 digits
        1. Collects the Item # and stores the value in Set() and changes to False Umbrella  
      2. If it is more than 16 digits, then stays in True Umbrella and continues 
        1. Collect() Item, Lot # and Expiry Date
    2. If it is false, then error message pops up and scan is not collected  

    False Umbrella 

    2. Checks IF the barcode is an item 

    1. If barcode is an item, then error message to scan the second barcode line.
      1. Error messages appears, and prevents scanning of new items unless this is completed. 
    2. If barcode is not an item,
      1. Combines the stored barcode info and concatenate() to the barcode that was just scanned and is then collected 
      2. Then resets the Umbrella back to True

     

    For the 2 lined barcode 

    I ended up using Set(), to store the first barcode value in a variable.  Ex. Set(Scan1, Barcode.Value) 

    When I was done with it, I just used Set(Scan1, Blank()) to reset the value.

     

     

     

     

     

  • WarrenBelz Profile Picture
    155,427 Most Valuable Professional on at

    Thanks @Anonymous ,

    Please consider accepting the post that assisted you the most as the Solution as it helps others find it more readily.

    It also closes the item.

     

  • KristofJ Profile Picture
    9 on at

    Its really bad that the out of the box functionality of the barcode scanner component in Power Apps doesn't support the use of GS1 AI's and GS's (Application Identifiers and Group Seperators). This while the DataMatrix functionality does support this. The funny thing is that Microsoft sabotages this deliberatly. If you scan a barcode with a GS in it, the component filters these out and passes the string without the GS's. To filter this out the component has to recognize the GS so i have no clue why they are doing this. 

    For those interested i made a loop that automatically takes all GS's. Also the variable ones. This for now only works on DataMatrix codes and works very well on Zebra Scanners.


    Cheers

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard