Tuesday, February 26, 2019

Dynamics NAV - Codeunit Extension


  • You cannot modify or extend an existing codeunit
  • You can create an entirely new codeunit
  • You can build subscriber functions that use existing publisher functions
  • Ensure you have compiled all objects in NAV
    • AL:Download Symbols to update VSCode with object names from NAV

  • tcodeunit = new codeunit structure
    • tprocedure = new method structure
      • Define Eventsubscriber trigger event (find details in development environment)
      • Define procedure to accept any parameters coming from the publisher
      • define vars
      • define code
codeunit 50100 ExtToolbox
{

trigger OnRun()
begin

end;

var
myInt: Integer;

[EventSubscriber(ObjectType::Page, Page::"Customer Card", 'OnAfterValidateEvent', 'Address', true, true)]
procedure ChangeMessage(var Rec: Record Customer; var xRec: Record Customer)

var
msg: Text[30];
msg2: Text[30];
begin
msg := xRec.Address;
msg2 := Rec.Address;
Message('Old Value:' + msg + ' | New Value: ' + msg2);
end;
}

No comments:

Post a Comment