Skip to content

[Event Requests] - Table 83 "Item Journal Line" #29576

@exnihiloo

Description

@exnihiloo

Why do you need this change?

  1. Please add an event publisher before the if "Qty. (Phys. Inventory)" >= "Qty. (Calculated") block in the OnValidate trigger of Qty. (Phys. Inventory).
    The event should include an IsHandled flag so extensions can skip the standard Validate("Entry Type") logic and assign the field value directly without triggering validation.

    Alternatives Evaluated: There are no events that we could use for our scenario. Our scenario requires to prevent from running validation trigger of field "Entry Type", the validation trigger of this field also does not have subscriber that we could exit validation trigger.

    Justification for IsHandled: We need to use IsHandled because without it standard code would trigger additional validations that conflict with custom process.

    Performance Considerations: This event is triggered only when a user manually enters or modifies ÔÇťQty. (Phys. Inventory)ÔÇŁ and "Qty. (Calculated)" in the Item Journal or when processing only report 790 "Calculate Inventory" runs. Expected performance impact is minimal, because the event mostly runs only during field validation.

    Data Sensitivity Review: The event exposes only current Item Journal Line, previous Item Journal Line and IsHandled. These records do not contain sensitive personal data, they include only operational inventory information such as Item No., Quantities, Posting Details.

    Multi Extension Interaction: Extensions that rely on this event must coordinate via dependency declarations. Partners can use EventSubscriberInstance = Manual to control execution order. The pattern is consistent with other core IsHandled events, so developers are familiar with the implications.

    Example of our custom code:

    if "Qty. (Phys. Inventory)" >= "Qty. (Calculated)" then begin
        //Validate("Entry Type", "Entry Type"::"Positive Adjmt."); //Standard code
        "Entry Type" := "Entry Type"::"Positive Adjmt.";  //Custom code
        Validate(Quantity, "Qty. (Phys. Inventory)" - "Qty. (Calculated)");
    end else begin
        //Validate("Entry Type", "Entry Type"::"Negative Adjmt."); //Standard code
        "Entry Type" := "Entry Type"::"Negative Adjmt.";  //Custom code
        Validate(Quantity, "Qty. (Calculated)" - "Qty. (Phys. Inventory)");
    end;
  2. Please add a new event publisher before the Validate("Setup Time") and Validate("Run Time") calls in the Concurrent Capacity field ÔÇô OnValidate trigger. The publisher should include an IsHandled parameter so extensions can override this logic and assign the values without executing the standard validation triggers.

    Alternatives Evaluated: The existing event OnValidateConcurrentCapacityOnAfterCalcTotalTime is insufficient because it does not allow to prevent the standard logic that validates Setup Time and always calculates Run Time using default formula. We also cannot run OnAfterValidate trigger because ÔÇťSetup TimeÔÇŁ and ÔÇťRun TimeÔÇŁ fields will be validated already.

    Justification for IsHandled: The IsHandled pattern is required because the standard system behavior always resets Setup Time, calculates Run Time using a default formula, and provides no built-in way to calculate Stop Time instead. When a Stop Code is entered, the business requirement is to preserve Setup Time, skip Run Time calculation, and calculate Stop Time using a custom formula. Without IsHandled, the standard logic would still run, overwriting Setup Time, calculating Run Time when it should not, and producing incorrect production journal entries, which would force unstable and unmaintainable workarounds. IsHandled allows the extension to safely bypass the standard Setup and Run Time logic, inject custom Stop Time calculations, and prevent conflicting or duplicate validations, making the required behavior possible.

    Performance Considerations: This event is triggered only when a user validates ÔÇťConcurrent CapacityÔÇŁ, "Starting Time", "Ending Time" on a production journal line. It does not introduce any measurable performance overhead, only checks Boolean and conditional logic.

    Data Sensitivity Review: The event exposes only current Item Journal Line, previous Item Journal Line and IsHandled. These records do not contain sensitive personal data, they include only operational inventory information such as Item No., Quantities, Posting Details.

    Multi Extension Interaction: Extensions that rely on this event must coordinate via dependency declarations. Partners can use EventSubscriberInstance = Manual to control execution order. The pattern is consistent with other core IsHandled events, so developers are familiar with the implications.

    Example of our custom code:

    trigger OnValidate()
    var
        ...
    begin
        ...
        WorkCenter.Get("Work Center No.");
        // **************
        //Validate("Setup Time", 0); 
        if "Stop Code" <> '' then begin
            Validate("Stop Time",
                    Round(
                    ("Ending Time" - "Starting Time") / CalendarMgt.TimeFactor("Cap. Unit of Measure Code") *
                    "Concurrent Capacity",WorkCenter."Calendar Rounding Precision"));
        end else
            Validate(
            "Run Time",
            Round(
                TotalTime / ShopCalendarMgt.TimeFactor("Cap. Unit of Measure Code") *
                "Concurrent Capacity", WorkCenter."Calendar Rounding Precision"));
        // **************
    end;

Describe the request

  1. OnValidate trigger field 54 "Qty. (Phys. Inventory)"
field(54; "Qty. (Phys. Inventory)"; Decimal)
{
    ...
    trigger OnValidate()
    var
        IsHandled : Boolean; //New local variable
    begin
        ...

        PhysInvtEntered := true;
        Quantity := 0;
        //Code change - Start
        OnBeforeCheckQuantity(Rec, xRec, IsHandled);
        If not IsHandled then
            if "Qty. (Phys. Inventory)" >= "Qty. (Calculated)" then begin
                Validate("Entry Type", "Entry Type"::"Positive Adjmt.");
                Validate(Quantity, "Qty. (Phys. Inventory)" - "Qty. (Calculated)");
            end else begin
                Validate("Entry Type", "Entry Type"::"Negative Adjmt.");
                Validate(Quantity, "Qty. (Calculated)" - "Qty. (Phys. Inventory)");
            end;
        //Code change - End
        PhysInvtEntered := false;
    end;

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckQuantity(var ItemJournalLine: Record "Item Journal Line"; xItemJournalLine: Record "Item Journal Line"; var IsHandled: Boolean)
begin
end;
  1. OnValidate trigger field 5849 "Concurrent Capacity"
field(5849; "Concurrent Capacity"; Decimal)
{
    ...
    trigger OnValidate()
    var
        WorkCenter: Record "Work Center";
        ShopCalendarMgt: Codeunit "Shop Calendar Management";
        TotalTime: Integer;
        IsHandled : Boolean; //New local variable
    begin
        ...
        WorkCenter.Get("Work Center No.");
        OnBeforeTimeValidation(Rec, xRec, IsHandled);
        if not IsHandled then begin
            Validate("Setup Time", 0);
            Validate(
              "Run Time",
              Round(
                TotalTime / ShopCalendarMgt.TimeFactor("Cap. Unit of Measure Code") *
                "Concurrent Capacity", WorkCenter."Calendar Rounding Precision"));
        end;
    end;
}

[IntegrationEvent(false, false)]
local procedure OnBeforeTimeValidation(var ItemJournalLine: Record "Item Journal Line"; xItemJournalLine: Record "Item Journal Line"; var IsHandled: Boolean)
begin
end;

Internal work item: AB#618274

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions