login

Tip of the Week

Tip of the Week – Barcodes in Salesforce are that bleeping simple

Barcode Scanner

Whether you’re managing 100 faxed applications a day, trying to follow items as they circulate on your shop floor, or you just need an easy way to track your inventory, you’ve likely run into a situation where you said, “wouldn’t it be so much easier if we could just scan a barcode?” Yes. Yes it would. There’s a reason barcodes are so popular. Just pull a trigger, listen to the satisfying bleep, and you’re in business. Most USB and Bluetooth barcode scanners work like a keyboard – when you scan a barcode, they type in the number and click Enter. This means that whether you’re using a standard search or a complex custom system, you don’t have to worry about crazy code. You can even use a barcode scanner with a mobile Salesforce1 app! But getting the barcodes themselves is another matter. Wouldn’t it be great if you could just automatically generate a barcode straight in Salesforce? Well, you can – and it’s free!

Adding barcodes to Salesforce is really simple. You’ll just need two new fields. Start off by creating the field that will hold the actual number – I’d recommend an autonumber field, but if you need more control, it can be plain text. Let’s call it Barcode #. Now, create a formula field and add the following code:

IMAGE("//www.barcodesinc.com/generator/image.php?code="&Barcode__c&"&style=325&type=C128B&width=200&height=50&xres=1&font=3",Barcode__c)

Using barcodesinc.com, a cool free service, a barcode will be instantly generated for you. And that’s it! Now you can add that field to Reports or List Views for printing, add them to your page layouts, include them in email templates, and the list goes on. With just two simple fields, you have a barcode for everything you might need. Now go get yourself a scanner and have fun!

-Jared and the Salesforce Guys

, , , , , ,

6 Responses to Tip of the Week – Barcodes in Salesforce are that bleeping simple

  1. Kent August 18, 2014 at 11:24 am #

    Great application note! I’ve been doing this in our org for a year now and it works great! I even have the bar code in a Visualforce page that is rendering as a PDF. However, I can’t send the PDF document out as an attachment on an email alert because the servers at Salesforce that process workflow can’t access the barcodesinc.com site. The bar code on the document just show up as a broken link.

  2. Michael Robbins July 25, 2016 at 6:52 pm #

    There are a few apps on the appExchange that do exactly what you want to do, using code that is resident on the platform, instead of calling out to a third party webservice. My favorite is Gimbal Barcode. https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000ptq1EAA

    • Jared Baker July 26, 2016 at 1:35 pm #

      Hi Michael,

      Could you give me and our readers some background on the pros and cons of Gimbal and what problems it solves for that the above solution doesn’t handle?

      • Michael Robbins July 26, 2016 at 4:12 pm #

        I think the pros and cons of using an app like Gimbal Barcode, instead of using a webservice like barcodesinc.com are probably as follows:

        1) Kent (comment above on 8/18/14) identified the following limitation, when using an external webservice to generate a barcode image for a PDF at run-time: the PDF doesn’t really contain black and white lines; the PDF contains a URL reference to a webservice that dynamically generates the image at run time, and which must be re-retrieved every time the PDF is opened. The adverse consequence of this if you save the PDF, and then attempt to open or render the PDF in an environment in which that webservice is inaccessible for some reason, or save it as a blob attachment, you’ll see a broken link instead of the barcode. In contrast, when creating a PDF using Gimbal Barcode, the PDF that is generated actually contains a series of black and white lines, within the body of the PDF. After saving the PDF, you could completely disconnect from the internet, open the PDF, and it will still display the same series of black and white lines. Gimbal Barcode can be used to SAVE a PDF as an attachment, that can then later be sent to an end-user by e-mail, if desired, and you can be sure that the end-user will see (and/or print) the barcode when they open it, regardless of their network environment.

        2) As developers, we have some sense of the reliability of the Salesforce.com servers, for better or worse. Although barcodesinc.com is free, we’d be caught totally flat-footed if it all of a sudden just “turned off”. It will work, until it doesnt. What do you tell your client, when that happens, and their business grinds to a halt?

        3) The primary “con” of Gimbal Barcode is probably the cost. It’s $36 per month PER ORG. Not free, but also not very expensive.

        • Jared Baker July 26, 2016 at 5:10 pm #

          Michael,

          Thank you for your helpful insight.

          Leveraging the solution in this tip, there are a few viable workarounds for printing barcodes which I’ve tested in the past – using Salesforce’s Printable View, and standard Reports both work splendidly. That said, the blob limitations can be tricky to handle (I’ve pulled a lot of late nights trying to find workarounds to things that should have been easy), and this is clearly a great solution.

          Regarding your point about barcodesinc.com dropping off the map, this is definitely a concern, however, it would likely not be difficult to find a viable replacement in short order.

          Finally, regarding the price, that is a very cost-effective AppExchange solution, and if the above concerns/issues are troublesome to a Salesforce client, Gimbal would probably be a fantastic replacement.

          Thanks again for the background! I may need to do a write-up in the future for our App of the Week!

          • Michael Robbins July 26, 2016 at 5:52 pm #

            If you ever need help with either a demonstration, or a trial, or an implementation of Gimbal Barcode, please don’t hesitate to ask. Thanks for publishing this handy blog!

Leave a Reply