A while back I did a blog posting on generating 2D Bar Codes, or QR Codes from Google’s Chart API. The demo was created back in the dark days of FileMaker 11, before the advent of the Insert from URL function (FM12). In the old demo I used a Custom Function and a free plugin to capture the result in FileMaker. With FileMaker 12 and 13, this process is much simpler, so I have decided to redo the demo file. I have also eliminated the use of a Custom Function to make the script more portable — you should be able to just paste this script into your solution and modify two input fields and one output fields to get it working.
Aside from the more common marketing uses for QR Codes, one potential use that I have been exploring is to employ them with UUIDs on identity cards. UUIDs are Univerally Unique Identifiers and can be used in lieu of Serial Numbers in particular when solutions are generating IDs “without significant central coordination”. For example if part of your solution is on the road in the form of a FileMaker Go database and you want these records to sync up with a master database at the end of the day, then UUIDs might be a good option to consider. Developers have been generating UUIDs in FileMaker for a while, using Custom Functions, but since FM 12, FileMaker has had the capability of generating UUIDs using the new Get(UUID) function.
FileMaker generated UUIDs are 36 character random hexadecimal digits. For example: 37E0B374-9640-498C-A1B7-2A753BD153D1.
Obviously, UUIDs are longer than most serial numbers (also more likely to be unique, because they are a lengthy and randomly generated) and as a result, less likely to be typed in manually—ideal then for a bar code scanner. In addtion, because they are longer, they are also a good match for QR Codes which are designed to handle more data than a standard bar code.
For more discussion about using UUIDs in FileMaker solutions, see FileMaker Standards.
QR Code Demo File
This is a very simple file.
- Enter some text in a record or generate a UUID
- Set the QR Code size (the field is set as a global, but it could be a regular field if you need to vary the size of your QR Codes)
- Push the ‘Get QR Code’ button
- Marvel at the cool QR Code.
The ‘Insert QR Code from Google’ API script
Modify the script for your solution
There are two areas of the script that will need to be modified if you paste this into your solution. 1) the setup fields: the Data and the Size and 2) the QR Code Container field.
I made the choice to make the bar code square. It does not have to be square, there is the capacity for the width and height variables to be different.
If your QR Code size will always be the same, you could skip the Size field and just hard code a number into $theSize variable.
The URL to send to the Google API
The script is forming a URL to send to Google, which returns the formatted QR Code. The URL syntax looks like this:
Trim ( Substitute ($theData ; ” ” ; “+” ) ) &”&chld=L|1&choe=UTF-8″
Simple Portable Code
This is just a simple example of what can be done in FileMaker 12 to generate QR Codes. The script is designed to be easily portable to other solutions, so I encourage you to experiment with it and let me know of any intersting uses you come up with for the technology.