Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Regarding - Clarification on Xml Port

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

Categories:
  • karthikeyani c Profile Picture
    karthikeyani c 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
    DAnny3211 9,217 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
    Marco Mels 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
    karthikeyani c 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
    karthikeyani c 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
    YUN ZHU 69,639 Super User 2024 Season 2 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
    DAnny3211 9,217 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
    Marco Mels 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans