Hello,
In the "Item Variants" page we have a customized field "Packsation" - "Packtisch". By validating or changing this field, the new value should also be updated on the "Packstation" field on the "Sales Line" table.
The error occurs in the Item Variants page and not in the Sales Order Subform page
Therefore, I have this code in the OnValidate trigger of the table:
trigger OnValidate()
var
SalesOrderLineMgmt: Codeunit "Sales Order Line Management";
begin
if Rec.Packstation <> xRec.Packstation then
SalesOrderLineMgmt.UpdatePackstation(Rec."Item No.", Rec.Code, Packstation);
end;
The UpdatePackstation will do the changes on the Sales Lines:
procedure UpdatePackstation(ItemNo: Code[20]; ItemVariantCode: Code[20]; NewPackstation: Enum "ACH Packstation")
var
SalesLine: Record "Sales Line";
begin
SalesLine.SetCurrentKey("Document Type", Type, "No.", "Variant Code", "Is Weighed", "Location Code", "Shipment Date");
SalesLine.SetRange("Document Type", SalesLine."Document Type"::Order);
SalesLine.SetRange(Type, SalesLine.Type::Item);
SalesLine.SetRange("No.", ItemNo);
SalesLine.SetRange("Variant Code", ItemVariantCode);
SalesLine.SetRange("Is Weighed", false);
SalesLine.SetRange("Location Code", BKLbl);
SalesLine.SetFilter("Shipment Date", '%1..', Today());
SalesLine.ModifyAll(Packstation, NewPackstation, false);
end;
The problem is this error only occurs directly in customers system environment and due to this, it's not possible to recreate this error locally or in development environment. Maybe the reason is the fact that multiple users a working parallely.
How can I solve this problem? By using a Tablelock maybe?
Thank you in advance!