Curious thing… last week a follower asked my if it’s possible to use the Camera with Dynamics 365 Business Central SaaS. My answer was obviously YES but he pointed me to a link on Docs where how to implement the Camera was explained, but only for the on-premise world (using the Microsoft.Dynamics.Nav.ClientExtensions assembly). Here it seems that you can do that only for the on-premise world, but this is not true.
For the SaaS world (but in general you can use it for all the environments) Microsoft has released a new Camera Interaction page that acts like a wrapper around these .NET assemblies and by using methods in this page you can capture images from Camera and use them in your AL extensions.
As an example, I have created a Take Order Picture action in the Purchase Order page for capturing the photo of a purchase order and attach it to the document card itself:
When you select this action, the camera of your device (if supported) starts and you can take a picture:
When the picture is taken, it’s saved on a Media field and it’s displayed on the Purchase Order page (in a cardpart object):
How to do that?
As a first step, I’ve added a new Media field called Image to the Purchase Header table:
Then, I’ve created a CardPart object for displaying the Image field on the Purchase Order page (in a part):
Last thing, I’ve created the Take Order Picture action in the Purchase Order page as follows:
Here, I’m using the Camera Interaction page. I set some properties for the Camera control and then I open the Camera (by using CameraInteraction.RunModal()). When the picture is taken, I call the GetPicture method for receiving the stream of the taken photo and I import this stream into the Image field.
Quite easy and I’m not using DotNet variables here. Last thing: yes, I think Microsoft should update their page on Docs about this topic…
UPDATE: you can also use the Camera page exactly like the Camera Interaction page. In the future the new Camera codeunit it will be the way to go (at least hoping so).