microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
785 stars 620 forks source link

[Event Request] Table 5406 "Prod. Order Line"."Variant Code".OnValidate #27497

Open fridrichovsky opened 2 weeks ago

fridrichovsky commented 2 weeks ago

Describe the request

Please add new event

field(12; "Variant Code"; Code[10])
        {
            Caption = 'Variant Code';
            TableRelation = "Item Variant".Code where("Item No." = field("Item No."),
                                                       Code = field("Variant Code"));

            trigger OnValidate()
            var
                ItemVariant: Record "Item Variant";
            begin
                ProdOrderLineReserve.VerifyChange(Rec, xRec);
                TestField("Finished Quantity", 0);
                CalcFields("Reserved Quantity");
                TestField("Reserved Quantity", 0);
                ProdOrderWarehouseMgt.ProdOrderLineVerifyChange(Rec, xRec);
                //--------------------------------------------OnValidateVariantCodeOnAfterVerifyChange:BEGIN
                OnValidateVariantCodeOnAfterVerifyChange(Rec, xRec, CurrFieldNo)
                //--------------------------------------------OnValidateVariantCodeOnAfterVerifyChange:END
                ItemVariant.SetLoadFields(Blocked, Description, "Description 2");
                if ItemVariant.Get("Item No.", "Variant Code") then begin
                    ItemVariant.TestField(Blocked, false);
                    Description := ItemVariant.Description;
                    "Description 2" := ItemVariant."Description 2";
                end else begin
                    GetItem();
                    Description := Item.Description;
                    "Description 2" := Item."Description 2";
                end;
                GetUpdateFromSKU();
                GetDefaultBin();
            end;
        }

//--------------------------------------------OnValidateVariantCodeOnAfterVerifyChange:BEGIN
[IntegrationEvent(true,false)]
local procedure OnValidateVariantCodeOnAfterVerifyChange(var ProdOrderLine: Record "Prod. Order Line"; xProdOrderLine: Record "Prod. Order Line"; CurrFieldNo: Integer)
begin
end;
//--------------------------------------------OnValidateVariantCodeOnAfterVerifyChange:END

Additional context

We need run acation before get Item Variant. Internal work item: AB#555762

AleksandricMarko commented 1 week ago

Hello @fridrichovsky, is there a chance you can use existing event OnAfterProdOrderLineVerifyChange from procedure ProdOrderLineVerifyChange

fridrichovsky commented 1 week ago

Hello @AleksandricMarko , We can not use suggested event because it is in function that is called from more places. We need some lines with validation and new values. It have to be only for Variant Code field.