Monday, December 28, 2015

My New Blog Home

Alas, it appears Microsoft’s Live Writer is no longer supported by Blogger so I have finally moved to WordPress (http://thatcrmblog.wordpress.com).
There will be a bit of a transition as I tweak the layout but I promise the orange is gone.

Wednesday, December 23, 2015

Dynamic QR Codes for Dynamics CRM


For some reason, Live Writer is failing to publish to Blogger which makes writing blogs tricky. Combined with the travel I am doing this Christmas means it will be tricky for me to knock out my usual three blogs a month. Either way have a great Christmas break ;)

I recently had a demo where I needed to generate QR Codes for CRM records and then make the codes available for printing. The scenario was for events where the QR code would appear on the invitee’s email and then the recipient could print it and be scanned at the event to confirm their attendance. This was something I had never done before and I was not sure it could be done. Generating QR codes is easy but dynamically generating a unique QR code for every Contact record in CRM and make it available for marketing is something else. Thankfully a bit of research (and a tiny bit of code later) and I was good to go.

What to Code

QR Codes can code practically any text you like. In this case I needed to code the web address for a Contact record. Every record in CRM has a unique web address which you can see when you click the ‘Email a Link’ button.











Generating the Code

The trick to generating the QR Code is the Google Charts API. In short, you construct the right URL and Google renders it as a QR code on the fly. For example, here is the QR code for my blog:


The API for QR codes is deprecated i.e. no longer supported by Google, but Google says it will remain active in the foreseeable future.

Now all we have to do is bring the CRM URL and the QR Code generator together, put the result in a field then add it to an email and we are set.

Bringing it Home

The first step is to access the unique web address of the record. To do this I use a workflow to populate a field on the Contact form with the record’s URL on creation.


The unique web address of the record is a special field accessible in workflows. Just look for ‘Record URL’.





The next step is to construct the web address and put it into the QR Code field so that when it is clicked, or added to an email, it will display the QR code.

In principle, this could also be done with a workflow but when I tried it would not work. It turns out the ‘&’ characters in the CRM URL for the Contact record confuses the Google API and we need to ‘encode’ the URL. This means replacing the ‘&’ with ‘%26’. Unfortunately I cannot do this with workflows or calculated fields so I needed to get some code written to do this and populate the QR Code field. Thanks to Steven Zhang for his flawless code (I have not got permission to provide the code but if you bribe your local dev they should be able to replicate the code without too much difficulty).

The end result is two populated fields on the Contact record which get populated on the Contact’s creation: one is a URL to the record and the other generates a QR code which, when scanned, also goes to the record.












In the case of our demo, we used ClickDimensions which allows you to add the web address of an image to an email template to be rendered on delivery, which was perfect.

Conclusions

The ability to generate QR codes on the fly for CRM records is very powerful. In this case I am using it for Contact records for events, but it could also be used for products for picking slips, for event flyers or to link with Adxstudio portals to direct non-CRM users to forms or sites so they can interact through the CRM portal.

Even outside of Dynamics CRM, the Google API for generating QR codes is a great tool to have in the toolkit.