web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 891

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,698 Moderator on at
    RE: Xmlport - How to skip first line of CSV import-file

    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
    891 on at
    RE: Xmlport - How to skip first line of CSV import-file

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

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: Xmlport - How to skip first line of CSV import-file

    Great.

  • Govinda Kumar Profile Picture
    2,304 Moderator on at
    RE: Xmlport - How to skip first line of CSV import-file

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans