Thursday, 21 February 2013

Salesforce and QR server integration for QR code generation in Salesforce

QR codes are very helpful in emails or business cards and often we get requirements in mobile application or a mail send to lead from salesforce to contain these QR code .

There has been lot of talks and debates on usability of this technology .Infact google has deprecated the API. Nevertheless some customers still prefer this technology and we often find QR codes in business cards ,front page of books ,Quotes and so on.

So this blog post demonstrates how to form the QR code in salesforce with the help of the qrserver

Please make sure to read the terms and conditions of the qrserver.com before using the QR code API for commercial  purpose .

There is already a good blog post from one of the MVP on this and hence it was very simple task for me to read and follow.Here is the link to the blog and it was nicely written.
http://www.tgerm.com/2012/11/salesforce-qr-code-visualforce-contact.html

The above blog used google chart API but since google have deprecated this API ,i had to look for the other websites providing me the API.

There were couple of good websites .

1)http://qrserver.com/api/documentation/create-qr-code/
2)http://www.sparqcode.com/static/QRGenAPI

In this blog i will be describing how to use formula field to generate the QR code using the qrserver.com API .The procedure remains same as we use with google chart API as demonstrated in the blog.

My assumptions are i have employee custom object and i have a formula field named QRCode and remote site settings has been configured for the http://qrserver.com/ .

so here is the formula using IMAGE function of the salesforce on how to bring the QR code from the qrserver.com

IMAGE('http://api.qrserver.com/v1/create-qr-code/?data='+ Name ,'hello',50,50)

Make sure to specify URL in small caps in image tag.For the readability purpose i have made all caps and in actual those are in small caps


data field consists of the content that will be displayed once the QR code is scanned by the reader.

Please note how the variable Name is used .Actually its  a merge field used from the formula editor and hence for each record this is dynamically populated .

50-Height of the image in pixel

50-Width of the image in pixel.

'hello '-string that will be displayed in case image fails to renders 



The QR image can be easily scanned with QR readers.There are number of readers available for mobile and the desktop.

I downloaded a QR code reader for my desktop from the URL below and works great .


From the screen the reader automatically scans the QR code and decodes the Text in it .

A small hint incase you need this image on the visualforce page here is the code to help

Hope the above information is helpful for people looking for sample approach on QR code generation in salesforce.





                                        

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...