Splitting Warehouse Shipment lines in multiple headers in Business Central
Xavier Garonnat
Posted on June 15, 2022
AL extensibility challenge : how to spread automatically Warehouse Shipment Lines on multiple Warehouse Shipment Header without being too much intrusive ? (with the constraint that the count of lines per document should now exceed a fixed value)
Just find the right event in the "Get Source Document" report and force the creation of a new header by setting WhseHeaderCreated to false when the condition is met :-)
[EventSubscriber(ObjectType::Report, Report::"Get Source Documents", 'OnSalesLineOnAfterGetRecordOnBeforeCreateShptHeader', '', false, false)]
local procedure OnSalesLineOnAfterGetRecordOnBeforeCreateShptHeader(SalesLine: Record "Sales Line"; var WarehouseRequest: Record "Warehouse Request"; var WarehouseShipmentHeader: Record "Warehouse Shipment Header"; var WhseHeaderCreated: Boolean; var OneHeaderCreated: Boolean; var IsHandled: Boolean);
var
WhseShipmentLine: Record "Warehouse Shipment Line";
begin
IF WarehouseShipmentHeader."No." = '' then
exit;
WhseShipmentLine.Reset();
WhseShipmentLine.SetRange("No.", WarehouseShipmentHeader."No.");
if WhseShipmentLine.Count = <MaxLinePerDocument> then
WhseHeaderCreated := false; //create new Whse Shipment Header
end;
I like simplicity :-)
💖 💪 🙅 🚩
Xavier Garonnat
Posted on June 15, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
webdev Understanding HTTP, Cookies, Email Protocols, and DNS: A Guide to Key Internet Technologies
November 30, 2024
softwareengineering Git Mastery: Essential Questions and Answers for Developers 🚀
November 30, 2024