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
Hi ,
Yes but I need to import the data only through xml port .
Without using excel buffer.
Thanks & Regards ,
Karthikeyani C
Hi
I would consider using the CSV Buffer Table, it is very simple
look at this
check my answer if it helped you, thanks
DAniele
Thanks a lot! Hope you will get the answer though you received a few suggestions here as well.
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
Hi Marco Mels,
Yes , I just posted the same in Developer's Forum .
Thanks & Regards,
Karthikeyani C
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.
Thanks.
ZHU
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
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.
I will open this up to the community in case they have something to add.
Thanks.
Sohail Ahmed
2,655
Mansi Soni
1,574
YUN ZHU
1,453
Super User 2025 Season 1