Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Scanning a QR Code and saving to SPL

(0) ShareShare
ReportReport
Posted on by 3,259

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:
  • Sajarac Profile Picture
    3,259 on at
    Re: Scanning a QR Code and saving to SPL

    Hey @lcimon , A big thank you !!!!!

     

    A little bit complicated but finally is working great. Thank you thank you thank you

    🙂

  • lcimon Profile Picture
    89 on at
    Re: Scanning a QR Code and saving to SPL

    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.

  • Sajarac Profile Picture
    3,259 on at
    Re: Scanning a QR Code and saving to SPL

    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!

  • Verified answer
    lcimon Profile Picture
    89 on at
    Re: Scanning a QR Code and saving to SPL

    @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,259 on at
    Re: Scanning a QR Code and saving to SPL

    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.

     

     

     

  • lcimon Profile Picture
    89 on at
    Re: Scanning a QR Code and saving to SPL

    @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,259 on at
    Re: Scanning a QR Code and saving to SPL

    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

  • Sajarac Profile Picture
    3,259 on at
    Re: Scanning a QR Code and saving to SPL

    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

     

  • lcimon Profile Picture
    89 on at
    Re: Scanning a QR Code and saving to SPL

    @sajarac,

     

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

  • Sajarac Profile Picture
    3,259 on at
    Re: Scanning a QR Code and saving to SPL

    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

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,522 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,890 Most Valuable Professional

Leaderboard