Share via


Importing and exporting NAV objects with C/Front

This post describes how you can automate importing and exporting of Microsoft Dynamics NAV objects with C/Front.

 

To make a basic C/Front project, see the post Beginners guide: How connect to NAV from a .net project, using C/Front. This post only describes the additional code needed to import or export NAV objects.

 

Exporting objects:

The line below will export Tables 1..10 to the file "C:\x\ExportFob.fob":

CFrontDotNet

.Instance.ExportFOB("C:\\x\\ExportFob.fob","WHERE(Type=CONST(Table),ID=FILTER(1..10))");

The filter has to be in the same syntax as used in the "DataItemTableView" in a report. The simplest way to create the filter is to make a new report in NAV, based on the Object Table. Then in the DataItem Properties, specify a filter in DataItemTableView, and copy that into your C/Front code.

The file that you export is a normal .fob file, which can be imported back in the usual way (File -> Import from Object Designer), or via C/Front as described next.

Importing objects:

C/Front has a special datatype "NavisionImportMode" to control the actions when the objects you import conflict with existing objects. The possible settings are Overwrite, Skip and ThrowError. The code needed to re-import the object we exported before, is:

NavisionImportMode ImportMode;

ImportMode = NavisionImportMode.Overwrite;

CFrontDotNet.Instance.ImportFOB("C:\\x\\ExportFob.fob",ImportMode);

 

Comments:

You can only export objects as binary .fob files. It is not possible to export objects as text.

In SP1 for NAV version 5, C/Front will no longer check for license permissions when importing files. So the import-functionality works just like importing objects manually, which means that the license file is not checked. In previous versions it was not possible to import new objects or tables with new fields unless the NAV license would allow the user to create those objects or fields manually.

 

 

Lars Lohndorf-Larsen

Microsoft Dynamics UK

Microsoft Customer Service and Support (CSS) EMEA

These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

Comments

  • Anonymous
    June 04, 2008
    Dieser Beitrag behandelt das Thema wie man Dynamics NAV Objekte mit C/Front automatisiert importieren

  • Anonymous
    June 05, 2014
    Hi Lars, I am writing a tool to export different objects but my where clause is not working properly. I am not able to export all the objects. If i do this then I get forms exported only. Table filter gets ignored. "WHERE(Type=CONST(Table),ID=FILTER(50003|50004|50007..50009),Type=CONST(Form),ID=FILTER(50013|50014|50017..50019))" Do you know what would be the correct way to export different types at the same time ? Regards, Mani