Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : bwglo1i8NRKrgl++we5HjX
Dynamics 365 Community / Blogs / Tina Menezes Blog / Procedure to skip caption r...

Procedure to skip caption row and other required rows while importing a .csv file via an XMLport in Dynamics NAV

Tina Menezes Profile Picture Tina Menezes 2,582

Introduction: In Dynamics NAV, .csv files can be imported via an XMLport which create corresponding records in Dynamics NAV. These .csv files usually have the caption row i.e. headings of the respective columns. This caption row needs to be skipped while being imported in Dynamics NAV. Also, at times the .csv file contains excess rows which are meant for information, they should not be imported and do not have an impact on record creation. Such rows need to be skipped too.

In this article, I will be showing a simple procedure to skip the first row containing column headings and the next three rows which are information based while importing the .csv file.

Pre-Requisites

  • Microsoft Dynamics NAV
  • .csv file containing the data to be imported

Procedure:

  1. Create two variables in C/AL globals. I have created a variable viz. ‘CaptionRow’ of DataType ‘Boolean’ for the caption row present in .csv file and another variable ‘CountVar’ of DataType ‘Integer’ for skipping remaining 3 rows following the caption row as shown below:

image001

  1. In the ‘OnPreXMLport()’, add the following code as below:

image003

  1. The structure of the XML port looks like below:

image004

 

  1. Now in ‘Table-Import::OnBeforeInsertRecord()’ add the following code:

image006

The above mentioned procedure will help to skip the header row and the rest rows which are not required to be imported.

For example, from the below .csv file the rows highlighted in red will be skipped i.e. the first 4 rows will be skipped and the import will directly start from the 5th row.

image008

Thank you!

 

 


This was originally posted here.

Comments

*This post is locked for comments