web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Xmlport - How to skip first line of CSV import-file

(0) ShareShare
ReportReport
Posted on by 911

I have a basic XMLPort to import a CSV file into the General Journal Line (81) BC table. This is working fine if I manually remove the header line at the top of the file.

I've seen various web-pages that say you can do something like the code below to skip the first line of the import-file. However, it still evaluates the data in the line instead of ignoring/skipping the line. It's reporting: "The length of the string is 21, but it must be less than or equal to 10 characters. Value: Journal Template Name".

1. Declare a global Boolean var (e.g.)
   var
          bFirstLine: Boolean;

2. trigger OnPreXmlPort()
    begin
       bFirstLine := true;
    end;

3. 

trigger OnBeforeInsertRecord()
var
begin
   if bFirstLine then begin
      bFirstLine := false;
      currXMLport.Skip();
   end;
end;

Am I using the wrong event perhaps? Any help would be greatly appreciated. Here's a sample of the data:-

"Journal Template Name","Journal Batch Name","Line No.","Account Type","Account No.","Posting Date","Document Type","Document No.","Description","Currency Code","Amount","Amount (LCY)","Shortcut Dimension 1 Code","Shortcut Dimension 2 Code"
"GENERAL","OPEN","6","G/L Account","TLPUK0099","01/01/2018","","00000400001","","EUR","100.000","95.460","",""
"GENERAL","OPEN","10","G/L Account","TLPUK0099","31/01/2018","","00000700001","Revalued Source","EUR","1","-5.370","",""
"GENERAL","OPEN","11","G/L Account","TLPUK0099","01/02/2018","","00000700002","Revalued Source REVERSING ENTRY","EUR","1","5.370","",""
"GENERAL","OPEN","14","G/L Account","TLPUK0099","28/02/2018","","00000800001","Revalued Source","EUR","1","-8.500","",""
"GENERAL","OPEN","15","G/L Account","TLPUK0099","01/03/2018","","00000800002","Revalued Source REVERSING ENTRY","EUR","1","8.500","",""

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Can you try this?

       trigger OnInitXmlPort()

       begin

           firstrow := true;

       end;

    trigger OnAfterInitRecord()

                   begin

                       if firstrow then begin

                           firstrow := false;

                           currXMLport.Skip();

                       end;

                   end;

  • Nick Webb Profile Picture
    911 on at

    Wow! That was quick. All fixed. Many thanks for your prompt response.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Great.

  • Govinda Kumar Profile Picture
    2,308 Moderator on at

    Please verify the solution if it worked, so others can benefit from this thread..

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,334 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,717 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,470

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans