I am developing a Extension using AL Language to create multiple Sales invoices. So I need to create Multiple sales Header records and each sale Header record having only one Sales Line.
end
I am developing a Extension using AL Language to create multiple Sales invoices. So I need to create Multiple sales Header records and each sale Header record having only one Sales Line.
end
Thanks Bidhi , great help . Resolved the issue adding
clear(SalesHeader);
clear(SalesHeader); //add this line first
SalesHeader.Init();
SalesHeader.Validate("Document Type", SalesHeader."Document Type"::Invoice);
SalesHeader.Validate("Sell-to Customer No.", CustomerNo);
SalesHeader.Validate("Bill-to Customer No.", SalesHeader."Sell-to Customer No.");
if SalesHeader.Insert(true) then begin
Remove "SalesHeader.Validate("Bill-to Customer No.", SalesHeader."Sell-to Customer No.");" line.
There is no need to do it. Read standard validation code for "Sell-To Customer No." field.
When you use Init, primary keys are not initialized.
You need to initialize the document number first, otherwise it will still refer to the 1st record.
example:
SalesHeader.Validate("No.",'');
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.
dynamicsuser.net/.../developers
I will open this up to the community in case they have something to add.
YUN ZHU
536
Super User 2025 Season 1
Mansi Soni
400
Sagar Dangar, MCP
384