Skip to content

[Event Request][W1][Table][246][Requisition Line] Add OnBeforeValidateQuantity and OnAfterValidateQuantity events to field 8 "Quantity" #10769

Description

@vveljovicaptean

Why do you need this change?

Table 246 "Requisition Line", field 8 Quantity, OnValidate. The first two statements of the
trigger assign the field and its base quantity unconditionally, before any publisher is reached:

Quantity := UOMMgt.RoundAndValidateQty(Quantity, "Qty. Rounding Precision", FieldCaption(Quantity));
"Quantity (Base)" := UOMMgt.CalcBaseQty(...);

The first publisher in the trigger, OnValidateQuantityOnBeforeGetDirectCost, sits inside
if Type = Type::Item then and is only reached after both statements have already run. Both
UOMMgt.RoundAndValidateQty and UOMMgt.CalcBaseQty raise rounding-precision errors, so for the
lines we care about the trigger errors out before any extension code can run at all. For line
types other than Item the trigger contains no publisher whatsoever.

Our solution plans supply for produce/manufacturing items whose base quantity is derived from our
own unit-of-measure model, and whose rounding-precision validation has to run at a different point
in the sequence and against a different precision than the base app applies. We need to substitute
those two statements for our own line types while leaving standard behaviour untouched for every
other line, and we need one point at the end of the trigger to run our follow-up validation in the
correct order.

Precedent: the sibling field in the same table already has this

Field 5408 "Quantity (Base)" carries exactly the pattern being requested:

trigger OnValidate()
var
    IsHandled: Boolean;
begin
    IsHandled := false;
    OnBeforeValidateQuantityBase(Rec, IsHandled, xRec, CurrFieldNo, CurrentFieldNo);
    if IsHandled then
        exit;

    TestProdOrderNo();
    TestField("Qty. per Unit of Measure", 1);
    Validate(Quantity, "Quantity (Base)");
end;

Quantity and "Quantity (Base)" are two entry points into the same calculation and only one of
them is extensible. This request makes the pair consistent.

Describe the request

Two new integration events on Table 246 "Requisition Line", field 8 Quantity, OnValidate.
Please add them to main and to the latest release branch.

Proposed publisher location

Object: Table 246 "Requisition Line"
Trigger: field(8; Quantity; Decimal) — OnValidate
Placement: OnBeforeValidateQuantity as the first statement of the trigger, ahead of
UOMMgt.RoundAndValidateQty; OnAfterValidateQuantity as the last statement, outside
if Type = Type::Item then, so it is raised for every line type.
Publisher declarations keep the alphabetical order already used in this object:
OnAfterValidateQuantity between OnAfterValidateFields and
OnAfterValidateShortcutDimCode; OnBeforeValidateQuantity immediately before
OnBeforeValidateQuantityBase.

**AFTER

        trigger OnValidate()
        var
            IsHandled: Boolean;
        begin
            IsHandled := false;
            OnBeforeValidateQuantity(Rec, IsHandled, xRec, CurrFieldNo, CurrentFieldNo);
            if IsHandled then
                exit;

            Quantity := UOMMgt.RoundAndValidateQty(Quantity, "Qty. Rounding Precision", FieldCaption(Quantity));

            "Quantity (Base)" :=
                UOMMgt.CalcBaseQty(
                    "No.", "Variant Code", "Unit of Measure Code", Quantity, "Qty. per Unit of Measure",
                    "Qty. Rounding Precision (Base)", FieldCaption("Qty. Rounding Precision"), FieldCaption(Quantity),
                    FieldCaption("Quantity (Base)"));

            if Type = Type::Item then begin
                // unchanged
            end;

            OnAfterValidateQuantity(Rec, xRec, CurrFieldNo, CurrentFieldNo);
        end;

Proposed publishers

[IntegrationEvent(false, false)]
local procedure OnBeforeValidateQuantity(var RequisitionLine: Record "Requisition Line"; var IsHandled: Boolean; xRequisitionLine: Record "Requisition Line"; CallingFieldNo: Integer; GlobalCurrentFieldNo: Integer)
begin
end;

[IntegrationEvent(false, false)]
local procedure OnAfterValidateQuantity(var RequisitionLine: Record "Requisition Line"; xRequisitionLine: Record "Requisition Line"; CallingFieldNo: Integer; GlobalCurrentFieldNo: Integer)
begin
end;

Provide an implementation (optional)

  • I will provide the implementation for this extensibility request

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions