- Michael Intravartolo
Microsoft Dynamics NAV 2016 - Implement the Camera in C/AL
Hi All,
With Microsoft Dynamics NAV 2016 Camera can be integrated with Dynamics NAV Client.

This article steps how we can add access to camera to a specific page from the development environment. Adding a camera option to the Item card, for example, lets you take a picture of a specific item and store it with the item.
Remember - Camera Integration will work only on Phone / Tablet Client.
In the development environment, on the Tools menu, choose Object Designer to open the Object Designer window.
In Object Designer, choose Pages, select the Item Card (page 30) and choose the Design button.
Add Picture in the general tab as shown below

4. From the Page Designer window, on the View menu, choose C/AL Globals.
Create the following two variables:
Variable Name: Camera
Data Type: DotNet
SubType: Microsoft.Dynamics.Nav.Client.Capabilities.CameraProvider.'Microsoft.Dynamics.Nav.ClientExtensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Variable Name: Camera Available
Data Type: Boolean
SubType:

5. Make sure to set the properties RunOnClient and WithEvents to Yes, for the Camera Dotnet Variables as shown below.

6. Let's Now add an action for Accessing Camera. Add a action with following properties -
Name: TakePicture
Enabled: CameraAvailable
Image - Camera
Promoted - Yes
Promoted Category: Process
PromotedIsBig - Yes
Add following code for the New Action Created
--------------------------------
Camera.RequestPictureAsync;
__________________

7. As we enabled WithEvents for the New Camera DotNet Variable. A new Trigger will be available as below:
-------------------------------------------------------------------------------
Camera::PictureAvailable(PictureName : Text;PictureFilePath : Text)
-------------------------------------------------------------------------------
Add following code for uploading Image In the Database.
-------------------------------------------------------------------------------
FileManagement.BLOBImportFromServerFile(TempBlob,PictureFilePath);
Rec.Picture := TempBlob.Blob;
Rec.MODIFY;
MESSAGE('Image Updated For Item %1 - %2',Rec."No.",Rec.Description);
FILE.ERASE(PictureFilePath);
-------------------------------------------------------------------------------

8. Now at last we only want to have the new action enabled only if camera is available & user is using the correct client.
In OnOpen Page of Item card add following Code.
-------------------------------------------------------------------------------
IF Camera.IsAvailable THEN
BEGIN
Camera := Camera.Create;
CameraAvailable := TRUE;
END;
-------------------------------------------------------------------------------
