bar code QR code scanning

  • 3
  • Question
  • Updated 2 years ago
  • Answered
Has anyone integrate this capability using the mobile device's capability to populate fields.  We are looking to track materials by scanning their bar and QR codes to find the product in the database.
Photo of Chad Gill

Chad Gill

  • 1,194 Points 1k badge 2x thumb

Posted 4 years ago

  • 3
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
We have not seen it done, but it completely should be feasible.  The device should be able to make the ID scanned from the QR code available to the browser, and you should be able to inject that value into a field using our Javascript API. 
Photo of Chad Gill

Chad Gill

  • 1,194 Points 1k badge 2x thumb
ah the search continues then for the limitations of SKUID
Photo of Seth Vanderdrift

Seth Vanderdrift

  • 878 Points 500 badge 2x thumb
Chad,

Did you ever figure this out?  We'll have the same need soon.

Thanks
Photo of Eric Robertson

Eric Robertson

  • 72 Points
There is a Java library, called zxing, that was particularly designed for the mobile use-case. I worked with it to develop a web application that will both generate and scan in QR codes and found it easy to work with. There are also complete code samples on the internet for scanning QR codes with the phone's camera and decoding them with zxing, as is discussed here:

http://stackoverflow.com/questions/23156399/how-to-decode-a-barcode-from-camera-preview-using-zxing-...

From there you could open a URL, passing the QR code's value in as a query string parameter, for example.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks Eric.  That sounds really sweet. 
Photo of Chad Gill

Chad Gill

  • 1,194 Points 1k badge 2x thumb
Did anyone get this running where you can scan a barcode value into a search field on salesforce1?
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 2,996 Points 2k badge 2x thumb
Processing a QR code is pretty easy in javascript (or, rather, there are several libraries that can handle this). The main issue is gaining access to your device's camera to get a live streaming video, which is pretty much the only way to make QR code scanning feasible.

Within the last couple years many browsers have begun adding the ability to access the device's camera from Javascript via the Media Streaming standard (aka getUserMedia). HTML5 support is slightly older, but didn't provide a way of accessing the camera from Javascript (it focused on uploading photos/videos to a server). Mobile browsers (ironically) have lagged behind the most in adding streaming support. Android only got this feature with version 5 (Lollipop) and iOS still does not support it. See the following URLs for more details:


The official specification is still in the draft phase, making this technology pretty bleeding edge (although I think it's probably stable at this point).

I'd expect general support (especially on mobile devices) to firm up in the next year or so, at which point a javascript-based QR code scanner will become much more feasible. I have personally taken an interest in this and actually built out a prototype roughly a year ago, but the mobile browser support was so bad back then that it was pretty much unusable. It'd be fun to revisit, now that Android has added support.

The following contains quote a lot of assumptions and guesses. It's not be rigorously tested, so definitely take with a grain of salt:

The Salesforce1 app uses a "web view" to render HTML content (I assume), so support for javascript APIs is going to be dependent on whatever browser is running on the system (guessing: they could override default browser capabilities to add or even remove support). On iOS, I'd guess that Salesforce1 is using Safari (even Chrome for iOS uses a Safari WebView, or so I've heard). On Android, I'm not sure if Salesforce1 uses the standard Android browser or if it respects a user-overridden default. In either case, it'll be dependent on the capabilities of the system's browser. So it's possible that a QR scanner would work in Salesforce1 on one Android device but not on another, depending on the OS version and the default browser selected by the user.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Just some anecdotal tidbits from me. The only mobile device I've successfully done a QR scan from is my Android with the Firefox browser installed on it. I've also gotten it to work in Chrome and Firefox on my laptop. (Kinda funny holding the QR code in front of my laptop's webcam though.
Photo of David Forder

David Forder

  • 120 Points 100 badge 2x thumb
We have an application built for scanning barcodes but they do require a bluetooth barcode reader - it works very well .. the code is scanned straight into the search box and the relevant product returned without a problem.

If anyone gets it working with a device camera let me know )