Generate QR Code for any Salesforce sObject in 5 Min

Reading Time: 3 minutes

What is a QR Code?
QR Codes are set to become the ‘next big thing’ but thinking to yourself, what is a QR Code!? QR or Quick Response Codes are a type of two-dimensional barcode that can be read using smartphones and dedicated QR reading devices, that link directly to text, emails, websites, phone numbers and more! You may have even got to this site by scanning a QR code!
Implementing in Salesforce:
You need to follow just simple steps to generate QR code for a sObject in Salesforce. So pick any sObject for this. I am taking Contact standard sObject. Follow these simple steps:
Note: Salesforce has two different desktop user interfaces: Lightning Experience and Salesforce Classic. This blog is designed for both versions.
Salesforce Classic:
1. Click on Setup. It is placed on Top-Right.
2. Then in Left panel, go to Customize –> Contacts –> Fields
3. Click on the New button to create the new custom field.
4. Select Formula field type here.
5. Fill field name with “QR Code” and Select Formula Return Type as “Text”
6. Then paste the following code in formula area:

Salesforce Lightning:
1. Click on Setup (Gear) Icon. It is placed on Top-Right.
2. Then in the Left panel, go to Object and Fields –> Object Manager
3. Here click on Contact object.
4. Go to Fields & Relationship from the sidebar.
5. Click on the New button to create the new custom field.
6. Select Formula field type here.
7. Fill field name with “QR Code” and Select Formula Return Type as “Text”
8. Then paste the following code in formula area:

Explanation of above code:
1. IMAGE(image_url, alternate_text [, height, width]) : Is a function to show image with giving URL.
2. https://chart.googleapis.com/chart chs=200×200&cht=qr&chl=https://cs87.salesforce.com/’& Id
2.1 https://chart.googleapis.com/chart : Is Google Chart API
2.2 chs: Height and width of QR Code
2.3 cht: Chart Type. We need to put qr for QR code
2.4 chl: QR Code will generate this text. (In our example I am putting URL of record)
Note: Please put your domain Url instead of https://YourDomain.salesforce.com
Now Save your formula field and open any record. You can see a QR Code on record.

Use QR Code Camera/App:
Now you can use any QR Code scanner app on mobile.
I am using Google Goggles. You can download from here:
https://play.google.com/store/apps/details?id=com.google.android.apps.unveil&hl=en
Now Open this app and scan your code. It will look like this:

Click on the generated link on the bottom of the screen. It will redirect to the record.

Happy Salesforce!!!

One thought on “Generate QR Code for any Salesforce sObject in 5 Min

Leave a Reply