You may have noticed that when people register for events in Dynamics 365 for Marketing the registration records include a QR code. But how can we use these to quickly check attendees into the event or individual sessions?
I’m currently running an event using Dynamics 365 for Marketing, I really wanted to use the QR codes to help make the check-in process quicker and less prone to human error. But I found this isn’t possible out of the box …. the reason is because the registration ID on the check-in form is a lookup field. In the mobile app we can only enable single line text fields to accept QR codes / Barcodes from the camera in our tablet or mobile phone.
Below you can see that as people register on the event portal an event registration record is created. This includes a QR code, currently we can’t easily email this QR code to attendees. (But that functionality will be available in a release soon!!) However we could print the QR codes out, maybe adding them to our attendee badges. So I’m still keen to use them.
To solve this challenge I created a custom field. Then I added it to my check-in form and enabled it for barcodes. Finally I added some JavaScript to trigger a search.
Note: In my brief description below I will assume you have a basic understanding on how to customize Dynamics 365. (Sorry!)
Step One – Create Field
First of all I created a field. I called it “new_codetext”. Obviously you could call it anything, but don’t forget that you will also need to adjust the JavaScript shown later in this post.
Notice that the data type is “Single Line of Text” as that is important!
Step Two – Add to Form and Enable for Barcodes
Next I added my new field to the “information” form of the check-in entity. I’ve put mine at the top of the screen but you could position the field anywhere.
Next you need to edit the field properties. In the controls tab of the field properties you can use the “Add Control…” link to add the Barcode Scanner control. Notice I have enabled this for phone or tablet. As I’ll be using the mobile client on these devices which supports accessing the devices camera.
Step Three – JavaScript
In this final step I needed to add some code which when the QR code is scanned will trigger a search for a registration.
Below you can see the field properties for the text field we just added to the form (new_codetext), I’ve added a form library containing my code. And in the event handlers I’ve set the OnChange event to executes a function called “Code_OnChange”.
Importantly I selected the option to pass the execution context in my onchange event! (I did this to avoid Xrm.Page commands.)
My JavaScript code is shown below;
function Code_OnChange(executionContext) {
var context = executionContext.getFormContext();
var code = context.getAttribute("new_codetext").getValue();
if(code == "" || code == null) {
return;
}
var queryString = "?$select=msevtmgt_name&$top=1&$filter=statecode eq 0 and msevtmgt_name eq '" + code + "'";
Xrm.WebApi.retrieveMultipleRecords("msevtmgt_eventregistration", queryString).then(
function success(result) {
if (result.entities.length == 1) {
var registration_Name = result.entities[0].msevtmgt_name;
var registration_Id = result.entities[0].msevtmgt_eventregistrationid;
var value = new Array();
value[0] = new Object();
value[0].id = registration_Id;
value[0].name = registration_Name;
value[0].entityType = "msevtmgt_eventregistration";
context.getAttribute("msevtmgt_registrationid").setValue(value);
context.getAttribute("msevtmgt_registrationid").fireOnChange()
}
},
function (error) {
alert("Ooops, something went wrong:" + error.message);
}
);
}
Having published my changes I can now scan QR codes when using the mobile application. As soon as a QR code is read the registration details are located and populated. Making the process of event check-ins quicker.
This is a simple change but one that I hope you can adapt to make the process of checking into events much quicker. Enjoy.