An interesting extension of the Microsoft Dynamics NAV Phone app has to do with the ability to retrieve pictures using the device camera, where available. This feature is duly described in MSDN: How to: Implement the Camera in C/AL
If you would like, then, to scan QR codes and Data Matrix in order to have an overview of the item assigned to that code, this could be easily implemented with a process close to the following:
- Take a picture
- Picture is saved server side
- A .NET Assembly (QR Code reader) scan QR Code and return the string decoded
- The string decoded is now actionable (e.g. open Item card)
How this could be done in practice?
1. Develop your own .NET Assembly to read QR Code
In this example, I have used the well-known ZXING library available on github.com.
See references below for documentation and usage disclaimer:
Just create a simple Visual Studio Solution that reference zxing and zxing.presentation libraries, accordingly to the target .NET Framework for your solution (e.g. .NET 4.5).
And code against them to have an image decoded as per the following
2. Deploy your .NET assemblies
Deploy the assemblies both server side and – for development only – client side in the Add-Ins folder. These are the relevant files that you have to place in the Add-Ins folders:
3. Create a QR Code Management code unit
In the Development Environment, create a new Codeunit called “QR Code Management” – or whatever you like – and add the following global function. DotNet data type runs as per default server-side.
4. Add QR Code to the Item table
Add a field in Table 27 “Item” called “QR Code” and map that field to both Page 30 “Item Card” and Page 31 “Item List”
Now, it is time to implement the MSDN coding to take a picture and store it server side.
Add the following code in Page 31 “Item List” OnOpenPage trigger
And create an action named “ScanQR” with the following properties and code
Last, but not least, when the PictureAvailable event is fired, implement some code that moves the picture into a specific folder – for better handling –, scan QR Code content and run the specific Page 30 “Item Card”, if this is recognized.
NOTE: images are never erased in C:\TEMP folder. Prepare your own batch/routine/ PowerShell script for an easy clean-up of the directory. If you have deployed IAAS solution using Microsoft Azure VMs, you might think of moving the images in the Temporary Storage disk (D:).
Have a good scan!
These postings are provided “AS IS” with no warranties and confer no rights. You assume all risk for your use.
Duilio Tacconi (dtacconi)
Microsoft Dynamics Italy
Microsoft Customer Service and Support (CSS) EMEA