microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
796 stars 622 forks source link

[Event Request] Codeunit 7302 "WMS Management".CheckItemJnlLineLocation #27701

Open fridrichovsky opened 5 days ago

fridrichovsky commented 5 days ago

Describe the request

Please add new event

procedure CheckItemJnlLineLocation(var ItemJournalLine: Record "Item Journal Line"; xItemJournalLine: Record "Item Journal Line")
    var
        WhseItemJournal: Page "Whse. Item Journal";
        TransferOrder: Page "Transfer Order";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeCheckItemJnlLineLocation(ItemJournalLine, xItemJournalLine, IsHandled);
        if IsHandled then
            exit;

        if ItemJournalLine."Entry Type" in
            [ItemJournalLine."Entry Type"::"Negative Adjmt.", ItemJournalLine."Entry Type"::"Positive Adjmt.", ItemJournalLine."Entry Type"::Sale, ItemJournalLine."Entry Type"::Purchase]
        then
            if ItemJournalLine."Location Code" <> xItemJournalLine."Location Code" then begin
                GetLocation(xItemJournalLine."Location Code");
                if not Location."Directed Put-away and Pick" then begin
                    GetLocation(ItemJournalLine."Location Code");
                    //-----------------------------------------------------------------OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick:BEGIN
                    IsHandled := false;
                    OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick(ItemJournalLine, xItemJournalLine, Location, IsHandled)
                    if not IsHandled then
                    //-----------------------------------------------------------------OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick:END
                        if Location."Directed Put-away and Pick" then
                            Error(Text011,
                              LowerCase(Location.TableCaption()), Location.Code, Location.FieldCaption("Directed Put-away and Pick"),
                              WhseItemJournal.Caption());
                end;
            end;

        if ItemJournalLine."Entry Type" = ItemJournalLine."Entry Type"::Transfer then begin
            if (ItemJournalLine."New Location Code" <> ItemJournalLine."Location Code") and
               ((ItemJournalLine."Location Code" <> xItemJournalLine."Location Code") or
                (ItemJournalLine."New Location Code" <> xItemJournalLine."New Location Code"))
            then begin
                GetLocation(ItemJournalLine."Location Code");
                ShowError := Location."Directed Put-away and Pick";
                if not Location."Directed Put-away and Pick" then begin
                    GetLocation(ItemJournalLine."New Location Code");
                    ShowError := Location."Directed Put-away and Pick";
                end;
            end;

            if ShowError then
                Error(Text012,
                  LowerCase(Location.TableCaption()), Location.Code, Location.FieldCaption("Directed Put-away and Pick"),
                  TransferOrder.Caption);
        end;
    end;

    //-----------------------------------------------------------------OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick:BEGIN
    [IntegrationEvent(true, false)]
    local procedure OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick(var ItemJournalLine: Record "Item Journal Line"; xItemJournalLine: Record "Item Journal Line"; var Location: Record Location; var IsHandled: Boolean)
    begin
    end;
    //-----------------------------------------------------------------OnCheckItemJnlLineLocationOnBeforeCheckErrorDirectedPutawayAndPick:END

Additional context

we need option how to skip error Text011. We have own check function. Internal work item: AB#558862

tomasevicst commented 2 days ago

If you have own check function, why you can't use OnBefore publisher and skip whole code. I don't see a reason to add publisher, only to skip one check.