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 / Drop Meaningless Chara...
Power Apps
Answered

Drop Meaningless Characters from BarCode Reader

(0) ShareShare
ReportReport
Posted on by 14

I have an app that I've been working on enhancing with the ability to use the Barcode Reader to read product numbers and enter them in to a text input field. I have the basics of this function working by assigning the following:

barCoilID: OnScan.Set(varCoilID, First(barCoilID.Barcodes).Value)
TextInput: Default.If(varCoilID = "", Parent.Default, varCoilID) (the text input will only accept numbers)

 

This works as intended however, our computer system puts a leading "s" in the barcode, which means nothing to our users. The product ID as a format of ######. I can use a Right(varCoilID, 6) in the Default property but I've found a few products that only have 5 digits. It's rare for that to happen, but I want to take as much error out of this as possible. 

 

Does anyone know a way to just drop the "s" from the scan without using a Right Function? I've tried using a Substitute function (Substitute(varCoilID, "s", "") in both the OnScan and Default properties and it doesn't seem to work. Any ideas would be greatly appreciated. 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @bgeorge76,

     

    The Substitute function should work - please keep in mind that this is case sensitive and will remove all occurrences within the scanned value.

     

    //Barcode reader OnScan
    Set(
     varCoilID, 
     Substitute(
     First(Self.Barcodes).Value,
     //Make sure this is the correct case
     "s",
     ""
     )
    )

     

    Alternatively you could use the following when s can occur multiple times but only the first one needs to be removed.

     

    Set(
     varCoilID, 
     With(
     {
     wBarCode: First(Self.Barcodes).Value
     },
     Right(
     wBarCode,
     //Should s always occur as a prefix, replace the Find() function with 1
     Len(wBarCode) - Find("s", wBarCode)
     )
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • bgeorge76 Profile Picture
    14 on at

    Both of those looked promising, but neither worked. Both returned errors of unexpected values. 

  • LaurensM Profile Picture
    12,516 Moderator on at

    @bgeorge76 my apologies, I had 1 closing bracket too many.

     

    I adjusted my initial comment accordingly. Would it be possible to try again?

  • bgeorge76 Profile Picture
    14 on at

    I just found the same thing. Tried both routines and got the same error that s##### could not be converted to a number. 

  • LaurensM Profile Picture
    12,516 Moderator on at

    @bgeorge76 I am unfortunately not able to recreate that error. Where does this error exactly occur since we don't do any numeric conversions in the code mentioned above?

  • bgeorge76 Profile Picture
    14 on at

    Nevermind, I found the issue. It was a case sensitive error on my part. The barcode was returning a uppercase S, not a lowercase and I overlooked it. Your first example works perfectly. Thank you so much!

  • LaurensM Profile Picture
    12,516 Moderator on at

    That indeed explains the error, thanks for the update!

    Glad I was able to help! 😊

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard