QR codes can be useful and you might find a need for generating them inside of Infor CRM (Saleslogix). A QR code can represent a lot of different things, but in this article we will be creating QR codes that contain the URL to a record in the CRM web client (the value stored in the QR code is easily modifiable for other purposes as well). A customer of mine needed a quick way to generate QR codes for items in their warehouse so users there could scan the QR code and quickly get to the record the item is for in Infor CRM. This method worked great for that. In the sample code for this article, we will be placing a button on the toolbar for an entity page (any would work without modifying the code).
Forst of all, open a detail form for an entity, such as the AccountDetail form. Add a button to the toolbar, name it whatever you’d like and add an image. Then, in the OnClientClick of the button add the following code:
var qrSize = '300x300'; var entityUrl = location.protocol + '//' + location.host + location.pathname + '?entityId=' + Sage.Utility.getCurrentEntityId(); var googleUrl = 'https://chart.googleapis.com/chart?cht=qr&chs=' + qrSize + '&chl=' + entityUrl; var win = window.open(googleUrl); return false;
When the user clicks the button, the code will open a new browser tab with the QR code containing the URL to the record you are looking at.
The user can then print it, copy it into an email or whatever. Note, the size of the generated QR code can be changed by modifying the qrSize variable in the code.
What this code is doing is simply passing the entity URL to a free to use API from google that does the actual QR code generation. The URL will look like this:
If you wanted to, you could create that URL in a LoadAction on the form and set it as the image to a control on the screen and there would be no need to open the new tab with the QR code (although it makes it a bit harder to print).