Displaying barcode in Salesforce lightning experience natively

Here we cover an easy way to display barcode in lightning experience using a free appexchange app Barcode and QR Code Generator.

This app allows you to generate barcode in Salesforce without depending on any external services. In below example, we are assuming that you have the app installed already. If not please go to Barcode and QR Code Generator and install.


Example - Displaying barcode using email field in lead

Here we will go through an example of displaying barcode using data from email field in lead records. This is just one example. Same approach will work for any other field in any custom/standard object in Salesforce.


1) Create a barcode config record for lead email field

Go to "Barcode Configs" tab that comes with the app and create a new record. Give it a name without spaces or special characters. Specify lead as object name and email as field name. You can leave other fields with default values. Then save the record. Please check below screenshot,

2) Add Barcode component to lead flexipage and activate

Once you have created a barcode config record, it is just matter of editing lead flexipage and adding "Barcode and QR Code Generator" component to the page.

First go to a lead record details page. Click Gear Icon and "Edit Page".

Drop "Barcode and QR Code Generator" component from left sidebar to the place you need. It will ask for a configName. Give the name of the record you created from step 1.

Click "Save" button on top right and finally click "Activation" on top right and assign the page as organization default (or based on your app or profile preferences).


Result

If you followed the steps correctly, you should see barcode when you go to any lead record page.


Use cases

Barcode generation and scanning can be used to improve a lot of business processes. Some examples are,

  • Generate product barcodes and stick labels to products so that you can scan and add products to opportunity
  • Generate QR code corresponding to your event registration custom object field(Id or registration number) and email users, so that you can scan in participants at the time of the event
  • Stick a QR code in your outgoing shipments and incoming shipments and then scan it into Salesforce records so that you can track shippings end to end
  • Need to scan the barcode values to Salesforce as well? Check out the article here

59 comments:

  1. Hi, I have installed this. Looks got so far. Now I come up with another question.

    My Use Case it to about attendee management. I store all registrations within a custom object related to a Lead. Now I would like to store and send out the QR Code by Email from the custom registration record using process builder or list emails. What´s yours suggestion to make this happen

    ReplyDelete
    Replies
    1. Glad to hear. Thank you for the feedback.

      I would recommend enabling Salesforce site and exposing a custom page that exposes barcode component. Then include that URL with some parameters in your registration emails. Please drop an email to albertsfo1@gmail.com if you would like to get on a call and discuss in detail.

      Delete
  2. Hello Is there a way to add the Field Name/Custom Label over the Generated Code? Our Use Case is that we are generating 2 Codes per record - referring to 2 fields. And we need to distinguish that which Code refers to which field.

    ReplyDelete
    Replies
    1. By default the data used to generate the barcode should be displayed below the barcode itself. Does that work in your use case?

      Delete
  3. Is this QR code compatible with the mobile app?

    ReplyDelete
    Replies
    1. Yeah. It will work in mobile app. You can either surface it as a quick action or in a flexi page.

      Delete
  4. I have installed the package and it looks good thus far. I have a specific use case that the generated QR code needs to be printed on a membership card from within Salesforce. Previously we solved this using an external service to generate the code and displaying it in a formula field for printing purposes. I would really like to move away from external service for the generation. Any input on how your tool may facilitate this?

    ReplyDelete
  5. I installed the app in my dev box. I am getting an error saying "refused to connect" is there something I missed in the set up process?

    ReplyDelete
    Replies
    1. I just tested in chrome and firefox. It is working fine. Which browser are you using?. Looks like a browser security setting blocking iFrames. Can you please try adding a CSP setting for the app's namespace under Setup => CSP Trusted Site. "https://yourMyDomainNameHere-dev-ed--barqr.visualforce.com" is the URL to whitelist

      Delete
    2. Tried whitelisting it and still says --barqr.visualforce.com refused to connect.

      Delete
    3. I'm also getting that error, added the url to the whitelist. Any thoughts?

      Delete
    4. It's do to clickjack protection, set in session settings. can add visualforce trusted domains, under trusted domains. That resolved it in my case.

      Delete
  6. Hello,

    Is there a way I can include this generated barcode in a vf page

    Thanks,
    Sujith

    ReplyDelete
    Replies
    1. You can use it in a VF page. There is a VF page that is included as part of the package. You just need to pass recordId and barcode config record names as parameters to the page.

      Delete
    2. What if I want to include barcode in already existing VF Page?
      I can see that there is a VisualForce component BarcodeVFComponent. Would it be possible to make the component global so it can be resued?

      Delete
  7. Hi, this is great. Is there a way to access to generated bar code via a URL, so I can use it somewhere else, e.g. in a document?

    ReplyDelete
    Replies
    1. You can create a lightning page that uses the component. Then dynamically pass the recordId as parameter to the page

      Delete
  8. Hi, is very useful app. But can i create a QR by more than one field? and can i do it ?
    Thanks

    ReplyDelete
    Replies
    1. You just need to create different barcode config records corresponding to the fields. Then drop the lightning components multiple times to the page each time specifying a separate config name.

      Delete
  9. Very useful app. Easy configuration. Thank you for the article

    ReplyDelete
  10. Hi I am having issues with the url that I am using to redirect the User using the QR Code. It does not seem to like the & in the url any advice

    ReplyDelete
    Replies
    1. This issue is fixed now. Basically earlier & character was getting escaped as &. In new version of the app, it should render correctly.

      Delete
  11. I have added this barcode on account object to generate barcode from external id field. I need to send this barcode for every account record to external system via api call in json. how do i acheive this

    ReplyDelete
    Replies
    1. That would require some custom development on top of the app. Would you like to drop an email to albertsfo1@gmail.com with details?

      Delete
  12. Hello! I have setup a QR code to display on assets. It appears correctly on the page but when I try to scan it, it does not open Salesforce. What I am missing ?

    ReplyDelete
    Replies
    1. This app is only for generating barcode. If you want to scan the record and do some custom actions, you might need a mobile app like this one - https://salesforcecodes.blogspot.com/2021/06/how-to-scan-barcode-values-and-send-to-salesforce.html

      Delete
    2. I just want to be redirected to salesforce record when I scan th e code using my Iphone. Any mobile app should allow that, isn't it ?

      Delete
    3. @admin I've just checked, and I have the same redirection problem in the Sandbox where I tested the QR code : scanning the code do not redirect to Salesforce anymore. Instead it opens Google to search for the Salesforce record name.

      Delete
    4. I think that is more specific to the app you are using to scan. Is your QR code, corresponding to the URLs of the asset?

      Delete
  13. Hi, Can I add more objects and fields to generate a QR code in the Barcode Config?

    ReplyDelete
    Replies
    1. You can create as many barcode config records as needed. Please use different names. Then drop the component to the page multiple times and specify the name of the config you want to display there.

      Delete
  14. Would it be possible to export the qr code image in a report? I'm trying to export this information with names so we can build badges for our volunteers. Any advise on how?

    ReplyDelete
  15. Hi,this is an amazing app!
    I have a question that is it possible to add vf component into vf page created by myself. I have tried to use BarQR:BarcodeVFComponent into my vf page but the barcode doesn't display. By the way, I want use the barcode in vf page as pdf at last.
    wait for reply.
    best regards
    Lee

    ReplyDelete
    Replies
    1. And I have configed the parameters in the url and make sure them work well by use them in the vf page that you provide

      Delete
    2. You configed which parameters in the url please ?

      Delete
    3. I'm facing the same issue tryint to use the component on a VFpage
      but no luck

      Delete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Really love this. Just a few questions:

    Any chance to centre the barcode, via Barcode Configuration?
    Any chance to show text with some basic font options, and a little padding?

    These are just small visual things, but the thing works so great, I would love to keep using it.

    ReplyDelete
    Replies
    1. Glad to hear. I can add these enhancements to our backlog.

      Delete
    2. Hello admin, whatever happened with the enhancements for font options and centering?

      Delete
  18. To Whom It May Concern, We are an nCino shop using their nCino Form Generation. Is there a method by which to embed the dynamic bar code into a form, so that upon generation the bar code is automatically rendered?

    ReplyDelete
    Replies
    1. I am not very familiar with nCino form generation tool. Please drop an email to albertsfo1@gmail.com. We can setup some time to debug this.

      Delete
  19. Hey - I cannot get the barcode to generate in the page layout :(

    ReplyDelete
    Replies
    1. Are you seeing some error? Can you please share more details?

      Delete
  20. Hello, I have configured the barcode as described, but when I add it to Accounts layout I get this error on that block "barqr.visualforce.com refused to connect".

    Am I missing anything???

    ReplyDelete
    Replies
    1. This is because session settings in your Salesforce environment. Go to Setup -> Session Settings -> uncheck "Enable clickjack protection for customer Visualforce pages with headers disabled"

      Delete
  21. Hello - very nice app. Thanks for your work. Wondering if the generated barcode may be placed on an Experience Site page? I tried just now to insert and it seems that it does not recognize the parameters as input in the Platform.

    ReplyDelete
  22. Hello! Do you have any documentation on how we can embed the generated QR Code to the emails we send out? Or maybe if you have a full documentation of all the capabilities of the package we can read through, that would be great.

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. everything was going good. worked on the detail page. but putting on a Salesforce site (community site) the componat is there awesome. but the barcode not showing up

    ReplyDelete
  25. Hi Admin,

    I created a configuration on Case object for CaseNumber field and Bar Code Type = Code 128. But when scanning it using BarCodeToCloud app in mobile its giving an error:

    Salesforce Operation
    Operation: update
    Object: Case
    Status: error
    Message: ["message": InCreatedDate, Id FROM
    Case WHERE = '09655795' LIMIT 1\n ^\nERROR
    at Row:1:Column:91\nunexpected token:
    '='"'"'errorCode":"MALFORMED_QUERY"}]
    id:

    Fields that I have selected for display/edit are:
    Account_name_Formula__c
    Assetld
    BusinessHoursid
    CreatedDate

    I followed the video to all the setup but still not working. Can you please help here.

    ReplyDelete
  26. Hello! We installed this package into a salesforce org and it was working great. However, now the QR code is not working only for androids, works fine for iphones. How can this be troubleshooted or resolved?

    ReplyDelete
  27. Thank you for this comprehensive blog post! It's a great resource for those of us considering AWS certifications. The detailed breakdown of the different certifications is especially helpful. Please visit our website:- amazon aws certification

    ReplyDelete
  28. Hello,

    The app is working fine with QR code generation,
    however I'm trying to find out how could we include the generated image in an email template?
    Could anybody help please?

    ReplyDelete
    Replies
    1. I was also not able to do this same thing. I have gone with a different solution.

      using Data Type Formula
      IMAGE('https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl='+Id,'QRCode')

      Delete