Tag Archives: NAV 2017

Fetch Filename from Directory using DotNet Datatype-NAV 2017

During recent implementation got task to fetch the files from specified directory to import in tables using XMLPORT and I was using NAV 2017.

Now in classic version we were able to use FILE and this virtual table was giving us the list of files in specified path by using required filters and we were able to import data from multiple files.

Coming to latest version to find the files in directory I used DotNet variables as follows

From one of the folder I am fetching the filename as follows

folder1

Define the variables as follows

Name             Data Type               Sub type                                                       Length
gvDirectory  DotNet                      System.IO.DirectoryInfo.’mscorlib’
gvFile             DotNet                      System.IO.FileSystemInfo.’mscorlib’
gvArr              DotNet                       System.Array.’mscorlib’
i                        Integer

In one codeunit write following program

gvDirectory:=gvDirectory.DirectoryInfo(‘E:\WorkingFolder\Target\’);
gvArr:=gvDirectory.GetFileSystemInfos();
FOR i:=0 TO gvArr.Length-1 DO
BEGIN
gvFile:=gvArr.GetValue(i);
Name:=gvFile.Name;
END;

Message(Name);

 

message

 

This will help in importing the multiple/sequential’s files in tables using XMLPORT.

Let me know yours feedback.

Cheers

 

Advertisements

Media Datatype-NAV2017

In this blog will try to explain how Media data type works in NAV2017 for uploading media,image.

Media data type store media in system tables of the database and then reference the media from application records. Media datatype provided better performance than traditional BLOB datatype. With BLOB datatype ,media is rendered every time in the client ,Media datatype provides unique Media ID to provide the data to client.

Table fields support data types for adding media to records. You can import media directly to a record . This media will get store in the system table Tenant Media with the unique identifier (ID). 

The media data type is associated with single media.

HOW TO USE MEDIA DATATYPE

Following example illustrate how to use Media data type in development.

Table

Field Id Field Name Data type
1 PictureNo Integer
2 MyPicture Media

Create list page and card page with above fields

Create one Action button on Page for importing the image.

Define following variable

filename   Text   250

MediaID   GUID
filename:=’E:\Photo.jpg’;
IF filename<>” THEN BEGIN
MediaID :=Rec.MyPicture.IMPORTFILE(filename,’Media Image’+FORMAT(Rec.PictureNo));
MODIFY;
END;

In tenant Media table following GUID will get inserted

tenant

Now Open the page in Web client and see the result

 

Following Media types are supported.

  • BMP
  • EMF
  • EXIF
  • GIF
  • JPEG
  • PNG
  • TIFF
  • WMF

You can use this method for applications that are developed for the Microsoft Dynamics NAV Web client and Microsoft Dynamics NAV Universal App:

  • Display media with records in list type pages, when the page is viewed in the Brick layout.
  • Display media on a card type page for a record.
  • Display media in a report.

 

Keep testing and let me know your feedback

Cheers….

Page Extension -Tenerife Visual Studio Code

In previous post Table Extension we saw how to extend table using Tenerife (New NAV development tool) .In this blog post we will see how to extend Pages using visual studio code.

The page objects extends a dynamics NAV page object .This will used for add or overrides the functionality.The structure of page is divided into three parts

  1. First part contains metadata for the entire page
  2. Second part describes visual parts on page
  3. Final Part describes action published on page

In visual studio typing tpageext will create the basic layout for page object when using AL extension in Visual Studio code.

 How to Write Code 

For example if you would like to add the custom field and Action button then you can wrtie code as follows.

pageextension

pageextension 70000030 VendorCardExtension extends "Vendor Card"
{
 layout
 {
 addlast(General)
 {
 field("Credit Days"; CreditDays)
 {
 CaptionML = ENU='CreditDays';

 trigger OnValidate();
 begin
 if CreditDays < 0 then
 Error('Credit Days Can not be blank');
 end;
 }
 }

 }

 actions
 {
 addlast(Creation)
 {
 group(MyActionGroup)
 {
 Action(MyAction1)
 {
 trigger OnAction();
 begin
 Message('Action Button is operating');
 end;
 }
 
 }
 }
 }

}

Keep Learning and Stay tuned for more updates…

Cheers…