Utilizing QR Codes in Salesforce

Haider Naseem
3 min readDec 25, 2020

--

QR Codes are more than what meets the eye. They are an easy way of embedding information into a small image that can easily be scanned to decode its data.

A QR code consists of black squares arranged in a square grid on a white background, which can be read by an imaging device such as a camera.

A QR code (abbreviated from Quick Response code) is a type of matrix barcode first designed in 1994. QR codes often contain data for a locator, identifier, or tracker that points to a website or application.

So, what can we create QR code for in Salesforce? And how can we do that?

For simple scenarios, QR codes can have links of salesforce records embedded in them. Upon scanning the QR codes, the user can be redirected to the record.

How we can achieve creating QR codes is what we will now be discussing. QR codes can be easily created using 2 simple ways:

  1. Using Formula Field.
  2. Using <img> tag.

When using a Formula Field to create QR code, we will be utilizing the IMAGE() function and Google Chart API.

  • IMAGE( image_url, alternate_text, height(px), width(px) ) : the IMAGE function needs 2 mandatory parameters- image_url and alternate_text.
  • Google Charts API:

Example:

IMAGE(‘https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=https://haidernaseem-dev-ed.my.salesforce.com/'+Id ,’Scan QR code to open record in mobile.’)

In the above example, you provide the IMAGE function with the Google Chart API link to your Salesforce record.

When using the <img> tag, you simply need to provide the “src” attribute with the Google Chart API link to your Salesforce record.

Example:

<img src=”https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=https://haidernaseem-dev-ed.my.salesforce.com/00128000003CycPAAS"></img>

The Formula Field can be used on the page layouts as usual in Classic as well as Lightning. Also, the <img> tag enables you to create the QR code in Visualforce components as well as Lightning Components.

Use Cases:

QR codes can be beneficial in Salesforce in following use cases:

  1. Send event attendee invites with QR codes, scan the QR code on day of event to mark attendance.
  2. Record the movement of inventory in and out of warehouses by scanning the QR codes.
  3. As a replacement to knowledge article links.
  4. Marketing
Formula Field created to display QR Code for Account Record
Visualforce created to display QR Code for Account Record

--

--

Haider Naseem
0 Followers

8x Certified Salesforce Senior Developer