Codeunit definition

All of the business logic for handling the requirements is defined in a GiftManagement codeunit, as follows:

codeunit 50101 "GiftManagement_PKT"{ procedure AddGifts(var SalesHeader: Record "Sales Header") var     SalesLine: record "Sales Line"; Handled: Boolean; begin     SalesLine.SetRange("Document Type", SalesHeader."Document Type");     SalesLine.SetRange("Document No.", SalesHeader."No.");     SalesLine.SetRange(Type, SalesLine.Type::Item);     //We exclude the generated gifts lines in order to avoid loops     SalesLine.SetFilter("Line Discount %", '<>100');      if SalesLine.FindSet() then     repeat         //Integration event raised         OnBeforeFreeGiftSalesLineAdded(SalesLine, Handled);         AddFreeGiftSalesLine(SalesLine, Handled);         //Integration Event raised ...

Get Mastering Microsoft Dynamics 365 Business Central now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.