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

Regarding - Clarification on Xml Port

(0) ShareShare
ReportReport
Posted on by 190

Hi Everyone

Hope all are fine..!

I just want to use xml port to create a new purchase order and in that the header table is working fine but there line table is not getting updated.

I here by write the following code , can anyone please let me know if there is any changes to be followed.

xmlport 50120 importpo
{
Caption = 'importpo';
Direction = Import;
Format = VariableText;
Permissions = TableData "Purchase Header" = rimd;
TextEncoding = UTF8;
UseRequestPage = false;
TransactionType = UpdateNoLocks;
FileName = 'doc.csv';

schema
{
textelement(Root)
{
tableelement(PurchaseHeader; "Purchase Header")
{
SourceTableView = where("Document Type" = const(Order));
// MinOccurs = Zero;
// MaxOccurs = Once;

fieldelement(DocumentType; PurchaseHeader."Document Type")
{
}
fieldelement(No; PurchaseHeader."No.")
{


}
fieldelement(BuyfromVendorNo; PurchaseHeader."Buy-from Vendor No.")
{
}
tableelement(PurchaseLine; "Purchase Line")
{
AutoSave = true;

LinkTable = "PurchaseHeader";
LinkFields = "Document Type" = field("Document Type"), "Buy-from Vendor No." = field("Buy-from Vendor No."), "Document No." = field("No.");
SourceTableView = where("Document Type" = const(Order), Type = const(item));
LinkTableForceInsert = true;
MinOccurs = Zero;
MaxOccurs = Once;


fieldelement(No; PurchaseLine."No.")
{
trigger OnAfterAssignField()
var
myInt: Integer;
begin
lineNo += 10000;
PurchaseLine.Validate("Line No.", lineno);
end;
}
fieldelement(quantity; PurchaseLine.Quantity)
{
}
trigger OnPreXmlItem()
var
myInt: Integer;
begin
PurchaseLine.SetRange("Document Type", PurchaseHeader."Document Type");
PurchaseLine.SetRange("Document No.", PurchaseHeader."No.");
end;


}

}
}
}
requestpage
{
layout
{
area(content)
{
group(GroupName)
{
}
}
}
actions
{
area(processing)
{
}
}
}
var
LineNo: Integer;

}

Thanks & Regards ,

Karthikeyani C

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

  • Suggested answer
    DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    Hi

    Sorry, I don't understand why you use this

    trigger OnPreXmlItem()

    var

    myInt: Integer;

    begin

    PurchaseLine.SetRange("Document Type", PurchaseHeader. "Document Type");

    PurchaseLine.SetRange("Document No.", PurchaseHeader. "No.");

    end;

    if you have to create rows from an xml, the layout must also contain the necessary data for the rows...like quantity for example, type=Item

    or you create them in AL code, but I don't understand where you pass the quantity.

    DAniele

  • Suggested answer
    YUN ZHU Profile Picture
    102,608 Super User 2026 Season 1 on at

    Hi, just an idea, you can import this data into an intermediate table (temp table) and then create the order from the temp table, which can do more processing.

    And here is an example of using Excel Buffer to import sales orders, hopefully it will give you some hints as well.

    https://yzhums.com/4223/

    Thanks.

    ZHU

  • karthikeyani c Profile Picture
    190 on at

    Hi Marco Mels,

    Yes , I just posted the same in Developer's Forum .

    Thanks & Regards,

    Karthikeyani C

  • karthikeyani c Profile Picture
    190 on at

    Hi Daniele Inclaza,

    Yeah I'm aware of that OnPreXmlItem trigger is used for Export Items in substitute of Linking Table .

    Even though I tried ,the data's are not getting updated / generated in the Purchase Order lines .

    Actually my requirement is :

    I just wanted to import as CSV file using XMLPORT (ONLY) in Purchase Order.

    Can you please provide me with some  sample procedure code.

    Please everyone if anyone is aware of it , kindly let me know .

    Kindly Regards ,

    Karthikeyani C

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Thanks a lot! Hope you will get the answer though you received a few suggestions here as well.

  • Suggested answer
    DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    Hi

    I would consider using the CSV Buffer Table, it is very simple

    look at this

    demiliani.com/.../

    check my answer if it helped you, thanks

    DAniele

  • karthikeyani c Profile Picture
    190 on at

    Hi , 

    Yes but I need to import the data only through xml port .

    Without using excel buffer.

    Thanks & Regards , 

    Karthikeyani C 

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 580 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 480 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 261 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans