ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Codeunit 900 - Assembly-Post - OnBeforeCheckPossibleToUndo

Open UIBKH opened this issue 3 years ago • 3 comments

Dear Support,

We would like to add a new event OnBeforeCheckPossibleToUndo in the following function using the IsHandled pattern. This would allow us to further customize the code and migrate existing customizations.

 local procedure CheckPossibleToUndo(PostedAsmHeader: Record "Posted Assembly Header"): Boolean
    var
        AsmHeader: Record "Assembly Header";
        PostedAsmLine: Record "Posted Assembly Line";
        AsmLine: Record "Assembly Line";
        TempItemLedgEntry: Record "Item Ledger Entry" temporary;
        IsHandled: Boolean; //New Code --++
    begin
        //New Code --
        IsHandled := false;
        OnBeforeCheckPossibleToUndo(PostedAsmHeader, IsHandled);
        if not IsHandled then 
        //New Code ++
            with PostedAsmHeader do begin
                TestField(Reversed, false);
                UndoPostingMgt.TestAsmHeader(PostedAsmHeader);
                UndoPostingMgt.CollectItemLedgEntries(
                TempItemLedgEntry, DATABASE::"Posted Assembly Header", "No.", 0, "Quantity (Base)", "Item Rcpt. Entry No.");
                UndoPostingMgt.CheckItemLedgEntries(TempItemLedgEntry, 0);
            end;

        with PostedAsmLine do begin
            SetRange("Document No.", PostedAsmHeader."No.");
            repeat
                if (Type = Type::Item) and ("Item Shpt. Entry No." <> 0) then begin
                    UndoPostingMgt.TestAsmLine(PostedAsmLine);
                    UndoPostingMgt.CollectItemLedgEntries(
                      TempItemLedgEntry, DATABASE::"Posted Assembly Line", "Document No.", "Line No.", "Quantity (Base)", "Item Shpt. Entry No.");
                    UndoPostingMgt.CheckItemLedgEntries(TempItemLedgEntry, "Line No.");
                end;
            until Next() = 0;
        end;

        if not AsmHeader.Get(AsmHeader."Document Type"::Order, PostedAsmHeader."Order No.") then
            exit(true);

        with AsmHeader do begin
            TestField("Variant Code", PostedAsmHeader."Variant Code");
            TestField("Location Code", PostedAsmHeader."Location Code");
            TestField("Bin Code", PostedAsmHeader."Bin Code");
        end;

        with AsmLine do begin
            SetRange("Document Type", AsmHeader."Document Type");
            SetRange("Document No.", AsmHeader."No.");

            if PostedAsmLine.Count <> Count then
                Error(Text011, PostedAsmHeader."No.", AsmHeader."No.");

            FindSet();
            PostedAsmLine.FindSet();
            repeat
                TestField(Type, PostedAsmLine.Type);
                TestField("No.", PostedAsmLine."No.");
                TestField("Variant Code", PostedAsmLine."Variant Code");
                TestField("Location Code", PostedAsmLine."Location Code");
                TestField("Bin Code", PostedAsmLine."Bin Code");
            until (PostedAsmLine.Next() = 0) and (Next() = 0);
        end;
    end;

Event Signature:

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCheckPossibleToUndo(PostedAssemblyHeader: Record "Posted Assembly Header"; var IsHandled: Boolean)
    begin
    end;

UIBKH avatar Mar 13 '23 12:03 UIBKH

Hello,

Thank you on your suggestion. With your proposal only check on Posted Assembly Header will be ignored. What about other constraints below Posted Assembly Header?

MarkoTrn avatar May 24 '23 11:05 MarkoTrn

We can add event

    IsHandled := false;
    OnBeforeCheckPossibleToUndo(PostedAsmHeader, IsHandled);
    if IsHandled then 
        exit;

AlexanderYakunin avatar Jun 06 '23 15:06 AlexanderYakunin

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.

Build ID: 11076.

JesperSchulz avatar Jun 10 '23 08:06 JesperSchulz