ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] codeunit 5855 "Release Invt. Document"

Open xtiche opened this issue 3 years ago • 3 comments

Please add events in codeunit codeunit 5855 "Release Invt. Document"

codeunit 5855 "Release Invt. Document"
{
    TableNo = "Invt. Document Header";

    trigger OnRun()
    begin
        // new event >>
        OnBeforeRun(Rec,IsHandled);
        if IsHandled then
             exit;
        // new event >>
        if Rec.Status = Rec.Status::Released then
            exit;

        InvtSetup.Get();
        if InvtSetup."Location Mandatory" then
            Rec.TestField("Location Code");
        Rec.TestField(Status, Status::Open);

        // new event >>
        IsHandled := false;
        OnBeforeCheckInvtDocLines(Rec,IsHandled);
        if not IsHandled then begin
        // new event >>
                InvtDocLine.SetRange("Document Type", Rec."Document Type");
                InvtDocLine.SetRange("Document No.", Rec."No.");
                InvtDocLine.SetFilter(Quantity, '<>0');
                if not InvtDocLine.FindFirst() then
                    Error(NothingToReleaseErr, Rec."No.");
                InvtDocLine.Reset();
        end;

        Rec.Validate(Status, Rec.Status::Released);
        Rec.Modify();
        // new event >>
        OnAfterRun(Rec,IsHandled);
        // new event >>
    end;

    var
        InvtDocLine: Record "Invt. Document Line";
        InvtSetup: Record "Inventory Setup";
        NothingToReleaseErr: Label 'There is nothing to release for item document %1.', Comment = '%1 - document number';

    procedure Reopen(var InvtDocHeader: Record "Invt. Document Header")
    begin
        // new event >>
        OnBeforeReopen(Rec,IsHandled);
        if IsHandled then
              exit;
        // new event >>
        if InvtDocHeader.Status = InvtDocHeader.Status::Open then
            exit;
        InvtDocHeader.Validate(Status, InvtDocHeader.Status::Open);
        InvtDocHeader.Modify();
    end;
}

xtiche avatar Jun 12 '23 05:06 xtiche

First event is not correct. And why do you need several events if you ask for first OnBefore handled event, which let you write you own implementation of this code?

AlexanderYakunin avatar Jun 12 '23 05:06 AlexanderYakunin

if be honest I need only OnBeforeCheckInvtDocLines(Rec,IsHandled);, but decided to ask more events for future, if anyway you will add one of them to object

xtiche avatar Jun 12 '23 05:06 xtiche

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: 11211.

JesperSchulz avatar Jun 20 '23 12:06 JesperSchulz