Skip to main content
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

  • karthikeyani c Profile Picture
    190 on at
    RE: Regarding - Clarification on Xml Port

    Hi , 

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

    Without using excel buffer.

    Thanks & Regards , 

    Karthikeyani C 

  • Suggested answer
    DAnny3211 Profile Picture
    9,280 Moderator on at
    RE: Regarding - Clarification on Xml Port

    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

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Regarding - Clarification on Xml Port

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

  • karthikeyani c Profile Picture
    190 on at
    RE: Regarding - Clarification on Xml Port

    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

  • karthikeyani c Profile Picture
    190 on at
    RE: Regarding - Clarification on Xml Port

    Hi Marco Mels,

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

    Thanks & Regards,

    Karthikeyani C

  • Suggested answer
    YUN ZHU Profile Picture
    86,093 Super User 2025 Season 1 on at
    RE: Regarding - Clarification on Xml Port

    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

  • Suggested answer
    DAnny3211 Profile Picture
    9,280 Moderator on at
    RE: Regarding - Clarification on Xml Port

    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
    Marco Mels Profile Picture
    on at
    RE: Regarding - Clarification on Xml Port

    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.

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans