ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] codeunit 112 "Empl. Entry-SetAppl.ID" - OnAfterUpdateEmplLedgerEntry

Open iltererdogan opened this issue 5 years ago • 1 comments

Hi,

Is it possible to add OnAfterUpdateEmplLedgerEntry publisher to Empl. Entry-SetAppl.ID codeunit?

    procedure SetApplId(var EmplLedgEntry: Record "Employee Ledger Entry"; ApplyingEmplLedgEntry: Record "Employee Ledger Entry"; AppliesToID: Code[50])
    var
        TempEmplLedgEntry: Record "Employee Ledger Entry" temporary;
        EmplLedgEntryToUpdate: Record "Employee Ledger Entry";
    begin
        EmplLedgEntry.LockTable();
        if EmplLedgEntry.FindSet then begin
            // Make Applies-to ID
            if EmplLedgEntry."Applies-to ID" <> '' then
                EmplEntryApplID := ''
            else begin
                EmplEntryApplID := AppliesToID;
                if EmplEntryApplID = '' then begin
                    EmplEntryApplID := UserId;
                    if EmplEntryApplID = '' then
                        EmplEntryApplID := '***';
                end;
            end;
            repeat
                TempEmplLedgEntry := EmplLedgEntry;
                TempEmplLedgEntry.Insert();
            until EmplLedgEntry.Next() = 0;
        end;

        if TempEmplLedgEntry.FindSet then
            repeat
                EmplLedgEntryToUpdate.Copy(TempEmplLedgEntry);
                EmplLedgEntryToUpdate.TestField(Open, true);
                EmplLedgEntryToUpdate."Applies-to ID" := EmplEntryApplID;

                if ((EmplLedgEntryToUpdate."Amount to Apply" <> 0) and (EmplEntryApplID = '')) or
                   (EmplEntryApplID = '')
                then
                    EmplLedgEntryToUpdate."Amount to Apply" := 0
                else
                    if EmplLedgEntryToUpdate."Amount to Apply" = 0 then begin
                        EmplLedgEntryToUpdate.CalcFields("Remaining Amount");
                        if EmplLedgEntryToUpdate."Remaining Amount" <> 0 then
                            EmplLedgEntryToUpdate."Amount to Apply" := EmplLedgEntryToUpdate."Remaining Amount";
                    end;

                if EmplLedgEntryToUpdate."Entry No." = ApplyingEmplLedgEntry."Entry No." then
                    EmplLedgEntryToUpdate."Applying Entry" := ApplyingEmplLedgEntry."Applying Entry";
                EmplLedgEntryToUpdate.Modify();

                // <<new
                OnAfterUpdateEmplLedgerEntry(EmplLedgEntryToUpdate, TempEmplLedgEntry, ApplyingEmplLedgEntry, AppliesToID);
                // >>new

            until TempEmplLedgEntry.Next() = 0;
    end;

    // <<new
    [IntegrationEvent(false, false)]
    local procedure OnAfterUpdateEmplLedgerEntry(var EmplLedgerEntry: Record "Employee Ledger Entry"; var TempEmplLedgEntry: Record "Employee Ledger Entry" temporary; ApplyingEmplLedgEntry: Record "Employee Ledger Entry"; AppliesToID: Code[50])
    begin
    end;
    // >>new

iltererdogan avatar Nov 23 '21 07:11 iltererdogan

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

JesperSchulz avatar Nov 30 '21 13:11 JesperSchulz