Skip to main content

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.

Thanks To +nishant srivastava  & +Riska Tirtasari  for the post, who suggested to have  this article.


Remember - Camera Integration will work only on Phone / Tablet Client.

1. In the development environment, on the Tools menu, choose Object Designer to open the Object Designer window.

2. In Object Designer, choose Pages, select the Item Card (page 30) and choose the Design button.

3. 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
DataType
SubType
Camera
DotNet
Microsoft.Dynamics.Nav.Client.Capabilities.CameraProvider.'Microsoft.Dynamics.Nav.ClientExtensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
CameraAvailable
Boolean



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;
 ------------------------------------------------------------------------------- 

For the Demo I used Microsoft Dynamics NAV 2016 W1.
You can download the Pre & post objects in Text Format from Dynamics User Group

Demo of Camera Integration -

Your Views on the article are much awaited. Stay connected, yet more to come.

Regards,
Saurav Dhyani

Comments

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searching for the error i figured out the issue was due to - Design change in NA

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.