Which trigger to implement this?

mysamzamysamza Posts: 47Member
I am trying to write code on Sales Order's subform;
Quantity Remaining = Quantity - Quantity Shipped - Reserved Quantity

Quantity Remaining is a new field I added by extending the Sales Line table and Sales Order Subform.

This value will be Quantity - Quantity Shipped - Reserved Quantity
However, Quantity Shipped only gets a value once the SO is shipped with the value in Qty to Ship.

I tried writing the following code on ExtendedSalesLineTable
trigger OnModify()

        IF rec."Quantity Shipped" <> 0 then begin
            recSalesLine.SetFilter("No.", Rec."No.");
            recSalesLine.SetRange("Line No.", Rec."Line No.");
            recSalesLine.SetFilter("Document No.", Rec."Document No.");
            if recSalesLine.FindFirst() then begin
                "Quantity Remaining" := (Rec.Quantity - Rec."Quantity Shipped") - rec."Reserved Quantity";

The problem is, I get Not Available in Rec.Quantity Shipped hence it always show me new field Remaining Quantity as 0.


  • ccorreiaccorreia Posts: 36Member
    You are using recSalesLine and then modify without making any change on that record?
    Also why don't you use for example a codeunit with eventsubscriber when table sales line is modified?
Sign In or Register to comment.