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 / Scanning a QR Code and...
Power Apps
Answered

Scanning a QR Code and saving to SPL

(0) ShareShare
ReportReport
Posted on by 3,284

Hello community.

 

Looking for some help here:

 

I am currently creating an app to scan QR codes. The QR code generated data is from a HTML Label, and basically is a string with the values of the selected record plus & Char(10) in between each field.

 

ie = BrowseGallery1.Selected.Title & Char(10) "&  BrowseGallery1.Selected.ID & char(10) ............etc.

 

I am getting the QR code with no issues. Now what I need to know is once the QR code is scanned I need to split that value or string to save each value in a Share point. Something like to break that line of text, create a collection and save each scanned code into a new row in my Share point list.

 

Somebody could please point me in the right direction?

 

Many thanks 

Categories:
I have the same question (0)
  • lcimon Profile Picture
    89 on at

    Hello,

     

    You can use the split function to break that line of text as following:

    Split(YourVariable, Char(10))

     

    With your example, you will get an array like ["TitleValue", "IDValue"].

     

    Then use the Patch function to save each row in your SharePoint list with something like:

    //Solution 1: If you don't need to add extra values
    Patch(YourSharePointList,
     RenameColumns(Split(pQRCodes, Char(10)), "Result", "YourColumnName")
    )
    
    //Solution 2: If you need to add extra values
    ForAll(Split(pQRCodes, Char(10)),
     Patch(Gateways,Defaults(Gateways), {YourColumnName: ThisRecord.Result, OtherColumn: XXX})
    )

     

  • Sajarac Profile Picture
    3,284 on at

    Hey, Thank you very much for the prompt response.

     

    However I have a small issue.

     

    For my OnScan property I have the following:

     

    Collect(collectMultiScan, {Barcodeinfo: BarcodeScanner.Value})

     

    In my gallery I was able to get the first line but with some issue doing this:

     

    Left(ThisItem.Barcodeinfo, Find(" ", ThisItem.Barcodeinfo)-1)

     

    But I guess still wrong.

     

    And after apply your formula I am getting error: expected a text value

     

  • lcimon Profile Picture
    89 on at

    @sajarac,

     

    I'm in trouble to understand what you want to achieve. Could you please elaborate a bit, please ? 

  • Sajarac Profile Picture
    3,284 on at

    Ok, Sorry for the mess.

     

    First thing first:

    The parameters for my QR Code are like this:

     

    HtmlText = 

    varRecord.MID& Char(10)&"ID: " &varRecord.Title & Char(10)&DataCardValue2&" Lbs" & Char(10) &"CreatedBy: " &varRecord.Employee

     

     

    This value is placed at the end of my Image property like this:

     

    "https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl="&QRdata

     

    That is how is generated the QR Code.

     

    Now to read the QR Code I have my app 

    Button Scan

    On Scan = Collect(collectMultiScan, {Barcodeinfo: BarcodeScanner.Value})

     

    I have a Gallery =

    Item = CollectMultiscan

     

    In my Gallery I have 2 labels so far trying to split the QR Code Code

     

    Label1 = Left(ThisItem.Barcodeinfo, Find(" ", ThisItem.Barcodeinfo)-1)

    Label2 = Right(ThisItem.Barcodeinfo, Find("CreatedBy:", ThisItem.Barcodeinfo)+2)

     

    And I have a button to patch my gallery

     

    Submit = 

    ForAll(collectMultiScan, Patch(TallySheet, Defaults(TallySheet),{Title:Label1.Text, Operator:Label2.Text}));Clear(collectMultiScan)

     

     

    This is what I have. I just need to patch my SPL "TallySheet" with all the values in my gallery matching Title = Title, Operator = Operator.

     

    Make sense?

     

    Sorry again

     

  • Sajarac Profile Picture
    3,284 on at

    the issue could be maybe because here I am using Char(10) instead of <br>?

     

    HtmlText = 

    varRecord.MID& Char(10)&"ID: " &varRecord.Title & Char(10)&DataCardValue2&" Lbs" & Char(10) &"CreatedBy: " &varRecord.Employee

  • lcimon Profile Picture
    89 on at

    @sajarac,

     

    Thanks for the clarification.

     

    So If I well understand, once a barcode is scanned, it is added into a Gallery where you want to split its content in 2 separate labels.

    A simple solution could be the following:

    Label1 = First(Split(ThisItem.Barcodeinfo, Char(10))).Result
    Label2 = Last(FirstN(Split(ThisItem.Barcode, Char(10)), 2)).Result

    Your patch formula seems to be correct and compatible with these formulas.

  • Sajarac Profile Picture
    3,284 on at

    Hey @lcimon ,thanks again for your help. Yes I need to split that Barcode string but where I am getting mental is because I need to split into 4 different pieces.

    Label1 = MID

    Label2 = Title

    Label3 = DataCardValue2

    Label4 = Employee

     

    I was able to get the Label1 and Label 4. But nothing for the values in the middle.

     

     

     

  • Verified answer
    lcimon Profile Picture
    89 on at

    @sajarac 

     

    Sorry I missed the other fields, here the updated formulas:

    Label1 = First(Split(ThisItem.Barcodeinfo, Char(10))).Result
    Label2 = Last(FirstN(Split(ThisItem.Barcodeinfo, Char(10)), 3)).Result
    Label3 = Last(FirstN(Split(ThisItem.Barcodeinfo, Char(10)), 4)).Result
    Label4 = Last(FirstN(Split(ThisItem.Barcodeinfo, Char(10)), 2)).Result

    (I might mixed up the labels)

     

    Basically, Split(ThisItem.Barcodeinfo, Char(10)) will split each part of your barcode into an array (based on the Char(10) as delimiter).

    Then, we have to get the right item at the right place. As PowerApps didn't provide a way to get an item by index, we need to use this workaround with Last and FirstN formulas. By example, for the 3d element:

    1. FirstN allows to get a subarray with the 3 first items.
    2. Last allows to get the last item of this subarray (ie. the 3d element of the main array)

     

    Hope it will help

  • Sajarac Profile Picture
    3,284 on at

    Yeaaahhhh. Finally the light at the end.

    I got the 4 fields divided which is great. Just one minor thing and I guess I have to figure out. Because in my QR Code it shows for instance:

    ID: 00000-27

    25 EA

    Operator: JK

     

    I need to remove using the substitute function to only get:

    00000-27

    25

    JK

     

    Other than that your solution is great!

  • lcimon Profile Picture
    89 on at

    You can achieve this using the Left & Right function to get only the part you need.

     

    An alternative would be to not include the part you don't need in the barcode like:

    HtmlText = varRecord.MID & Char(10) & varRecord.Title & Char(10) & DataCardValue2 & Char(10) 
    & varRecord.Employee

     

    Please consider to click on Accept as solution if my post help you to solve your issue.

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 462

#2
WarrenBelz Profile Picture

WarrenBelz 425 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 291

Last 30 days Overall leaderboard