AL Extensions: Accessing the Device Camera

If you’ve been doing any V2 extension development, you like are aware that we cannot use any .Net interop in our code.
While on premise V2 development will eventually gain access to .Net variable types, if you’re coding your extension to run in AppSource, you will remain locked away from using .Net interop in your code because the risk of these external components is too large for shared cloud servers.
Unfortunately this means that we lost the ability to interact with the device camera, as it was accessed using .Net.
In C/AL, the code to take a picture with the device camera looked like this:

   IF NOT CameraAvailable THEN
   CameraOptions := CameraOptions.CameraOptions;
   CameraOptions.Quality := 50;

It’s simple enough code, but the problem in the above example is that both CameraProvider and CameraOptions are .Net variables, and therefore cannot be used in V2 extension development.
I’m happy to say though that this problem has been resolved. Yes, the underlying architecture still uses .Net controls, but Microsoft has introduced a new Camera Interaction page which acts basically like an api layer. Through this api layer you can interact with the .Net camera components just as you did in C/AL.
Not a huge change to wrap your head around at all. In your extension you will code against the Camera Interaction page instead of against the .Net controls directly. Inside the page are all the original camera functions that you were used to using before.
This greatly simplifies our extension code and allows us now to use the camera from our extensions.
The code to take a picture would now look like this:

local procedure TakePicture();
        CameraInteraction: Page "Camera Interaction";
        PictureStream: InStream;
        if(CameraInteraction.GetPicture(PictureStream)) then begin
            Picture.ImportStream(PictureStream, CameraInteraction.GetPictureName());

That’s it! Now you can use the device camera from your V2 extensions.
Happy coding!

NAV 2015 is apptastic!

If you’re in the Dynamics NAV world, you probably already know that NAV 2015 has been released to partners (get it here), and will be available to the general public starting October 1.
One of the new features of NAV 2015 that has me very interested is the tablet interface.
This is a topic that has been kicked around a lot over the past few years with regards to the NAV products I’m involved with. At some point, there’s a line where adding more functionality just adds clutter to the end user. In an age where apps rule, users are quite adept at having a suite of apps that do fewer tasks, but more efficiently.
The tablet interface gives us a way to deal with in the ERP world. Yes I realize we could have been building apps for the past ‘x’ years, but that comes with a lot of overhead, especially if it means a NAV developer having to learn a new programming language. With the NAV 2015 tablet interface though, there’s no additional development that needs to be learned. If you can create pages, you can create tablet interfaces. For end-users, the ability to “pin” or “favorite” multiple NAV 2015 tablet URLs, means that they can essentially build their own toolbox of “apps”, based on the tasks they need to do. Of course, being cross-device compatible is pretty neat too!
I’ll cover more on this in the future as I get my hands dirtier with it, but for now let’s sit back and enjoy the fact that finally it’s easy to bridge the gap between ERP and your device.

© 2020 NAV Bits and Bytes

Theme by Anders NorénUp ↑