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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

XMLPort

(0) ShareShare
ReportReport
Posted on by 134

Hi all,

I am have created an XML port as an extension in VS Code for NAV2018. I am not managing to correctly set up the record separator as upon trying to import the CSV file, it tries to import the second line with the last field of the first i.e. when trying to import the below 2 records, I get an error saying G/L account '1240 PAYMENTS' does not exist; 

PAYMENTS,DEFAULT,31/12/2017,Payment,2017JE29,2017JE29,Vendor,V0001,"vendor recon as at 31.12.2017, adj in 2017",,,,,,,0.01,G/L Account,1240
PAYMENTS,DEFAULT,31/12/2017,Payment,2017JE29,2017JE29,Vendor,V0001,"vendor recon as at 31.12.2017, adj in 2017",,,,,,,0.01,G/L Account,1240

as if the XML port is not recognizing that a record has ended and a new one has started. 

In my XML port i have already tried to set the Record Separator property by adding ; RecordSeparator = '<<NewLine>>';

I have also tried the below;

Record Separator Result
RecordSeparator = '<<NewLine>>' error saying G/L account '1240 PAYMENTS' does not exist
RecordSeparator = '<NewLine>' imports only first line
RecordSeparator = '<CR/LF>' imports only first line
RecordSeparator = '<LF>' imports only first line

Format of the XML port is 'Variable Text' 

Any ideas on how to solve this, please? 

Categories:
  • Suggested answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    No need to specify Record Separator Property if you are using default , just specify the format as below will do :

    TextEncoding=WINDOWS;

    Format=Variable Text;

  • Y_NAV_1716 Profile Picture
    134 on at

    Thanks for the suggestions above. As previously stated, the format is already Variable Text. I tried adding 'TextEncoding = WINDOWS' and removed the record separator but I am still getting the same issue i.e. inserting only the first record.

    Any other suggestions?

    Thanks in advance!

  • I Gusti Made Ari Profile Picture
    3,608 on at

    Please assist to paste the full code  of the xmlport in here

  • Y_NAV_1716 Profile Picture
    134 on at
    xmlport 50100 "Import Journal Lines Excel"
    {
        Format = VariableText;
        TextEncoding = WINDOWS;
    
        schema
        {
            textelement(Root)
            {
                tableelement("Gen. Journal Line"; "Gen. Journal Line")
                {
                    AutoUpdate = true;
                    XmlName = 'GenJnlLine';
                    fieldelement(JTN; "Gen. Journal Line"."Journal Template Name")
                    {
                        Width = 10;
                    }
                    fieldelement(JBN; "Gen. Journal Line"."Journal Batch Name")
                    {
                        Width = 10;
                    }
                    fieldelement(PDate; "Gen. Journal Line"."Posting Date")
                    {
                        Width = 10;
                    }
                    fieldelement(DocType; "Gen. Journal Line"."Document Type")
                    {
                        Width = 10;
                    }
                    fieldelement(DocNo; "Gen. Journal Line"."Document No.")
                    {
                        Width = 50;
                    }
                    fieldelement(ExtDoc; "Gen. Journal Line"."External Document No.")
                    {
                        Width = 50;
                    }
                    fieldelement(AccType; "Gen. Journal Line"."Account Type")
                    {
                        Width = 10;
                    }
                    fieldelement(AccNo; "Gen. Journal Line"."Account No.")
                    {
                        Width = 10;
                    }
                    fieldelement(Desc; "Gen. Journal Line".Description)
                    {
                        Width = 250;
                    }
                    fieldelement(CurrCode; "Gen. Journal Line"."Currency Code")
                    {
                        Width = 10;
                    }
                    fieldelement(GenPostingType; "Gen. Journal Line"."Gen. Posting Type")
                    {
                        Width = 10;
                    }
                    fieldelement(GenBusPostingGrp; "Gen. Journal Line"."Gen. Bus. Posting Group")
                    {
                        Width = 10;
                    }
                    fieldelement(GenProdPostingGrp; "Gen. Journal Line"."Gen. Prod. Posting Group")
                    {
                        Width = 10;
                    }
                    fieldelement(VATBusPostingGrp; "Gen. Journal Line"."VAT Bus. Posting Group")
                    {
                        Width = 10;
                    }
                    fieldelement(VATProdPostingGrp; "Gen. Journal Line"."VAT Prod. Posting Group")
                    {
                        Width = 10;
                    }
                    fieldelement(Amt; "Gen. Journal Line".Amount)
                    {
                        Width = 10;
                    }
                    fieldelement(BalAccType; "Gen. Journal Line"."Bal. Account Type")
                    {
                        Width = 10;
                    }
                    fieldelement(BalAccNo; "Gen. Journal Line"."Bal. Account No.")
                    {
                        Width = 10;
                    }
                    fieldelement(BalGenPostingType; "Gen. Journal Line"."Bal. Gen. Posting Type")
                    {
                        Width = 10;
                        MinOccurs = Zero;
                    }
                    fieldelement(BalGenBusPostingGrp; "Gen. Journal Line"."Bal. Gen. Bus. Posting Group")
                    {
                        Width = 10;
                        MinOccurs = Zero;
                    }
                    fieldelement(BalGenProdPostingGrp; "Gen. Journal Line"."Bal. Gen. Prod. Posting Group")
                    {
                        Width = 10;
                        MinOccurs = Zero;
                    }
                    fieldelement(BalVATBusPostingGrp; "Gen. Journal Line"."Bal. VAT Bus. Posting Group")
                    {
                        Width = 10;
                        MinOccurs = Zero;
                    }
                    fieldelement(BalVATProdPostingGrp; "Gen. Journal Line"."Bal. VAT Prod. Posting Group")
                    {
                        Width = 10;
                        MinOccurs = Zero;
                    }
                }
            }
        }
    
        requestpage
        {
    
            layout
            {
            }
    
            actions
            {
            }
        }
    }
    
  • Verified answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    You had missed out "Line No." , this is part of primary key and without this only one will be inserted.

    Put below code on your XML Port to auto generate line No. :

                   trigger OnBeforeInsertRecord();

                   var

                       GenJournalLine : Record "Gen. Journal Line";

                   begin

                       GenJournalLine.SETRANGE("Journal Template Name","Gen. Journal Line"."Journal Template Name");

                       GenJournalLine.SETRANGE("Journal Batch Name","Gen. Journal Line"."Journal Batch Name");

                       if GenJournalLine.FINDLAST then

                          "Gen. Journal Line"."Line No." := GenJournalLine."Line No." + 10000

                       else

                          "Gen. Journal Line"."Line No." := 10000;

                   end;

  • Y_NAV_1716 Profile Picture
    134 on at

    Thanks! :)

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans