ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Сreate Event Request Table 37 "Sales Line" OnValidateLocationCodeValidateShortcutDimension1Code

Open VladimirTkalich opened this issue 3 years ago • 3 comments

Hello, could you please create OnValidateLocationCodeValidateShortcutDimension1Code event in the field 7 "Location Code" in the Table 37 "Sales Line"?

IntegrationEvent(false, false)] local procedure OnValidateLocationCodeValidateShortcutDimension1Code(var SalesLine: Record "Sales Line") begin end;

    field(7; "Location Code"; Code[10])
    {
        Caption = 'Location Code';
        TableRelation = Location WHERE("Use As In-Transit" = CONST(false));

        trigger OnValidate()
        var
            IsHandled: Boolean;
        begin
            TestJobPlanningLine();
            TestStatusOpen();
            CheckAssocPurchOrder(FieldCaption("Location Code"));
            OnValidateLocationCodeOnAfterCheckAssocPurchOrder(Rec);

#if not CLEAN20
IsHandled := false; OnBeforeUpdateLocationCode(Rec, IsHandled); #endif
if xRec."Location Code" <> "Location Code" then begin if not FullQtyIsForAsmToOrder() then begin CalcFields("Reserved Qty. (Base)"); TestField("Reserved Qty. (Base)", "Qty. to Asm. to Order (Base)"); end; TestField("Qty. Shipped Not Invoiced", 0); TestField("Shipment No.", ''); TestField("Return Qty. Rcd. Not Invd.", 0); TestField("Return Receipt No.", ''); end;

            GetSalesHeader();
            IsHandled := false;
            OnValidateLocationCodeOnBeforeSetShipmentDate(Rec, IsHandled);
            if not IsHandled then
                CalcShipmentDateForLocation();

            CheckItemAvailable(FieldNo("Location Code"));

            if not "Drop Shipment" then begin
                if "Location Code" = '' then begin
                    if InvtSetup.Get() then
                        "Outbound Whse. Handling Time" := InvtSetup."Outbound Whse. Handling Time";
                end else
                    if Location.Get("Location Code") then
                        "Outbound Whse. Handling Time" := Location."Outbound Whse. Handling Time";
            end else
                Evaluate("Outbound Whse. Handling Time", '<0D>');

            OnValidateLocationCodeOnAfterSetOutboundWhseHandlingTime(Rec);

            if "Location Code" <> xRec."Location Code" then begin
                InitItemAppl(true);
                GetDefaultBin();
                InitQtyToAsm();
                AutoAsmToOrder();
                OnValidateLocationCodeValidateShortcutDimension1Code(Rec)     /// NEW EVENT
                if Quantity <> 0 then begin
                    if not "Drop Shipment" then
                        UpdateWithWarehouseShip();
                    if not FullReservedQtyIsForAsmToOrder() then
                        VerifyChangeForSalesLineReserve(FieldNo("Location Code"));
                    WhseValidateSourceLine.SalesLineVerifyChange(Rec, xRec);
                end;
                if IsInventoriableItem() then
                    PostingSetupMgt.CheckInvtPostingSetupInventoryAccount("Location Code", "Posting Group");
            end;

            UpdateDates();

            if (Type = Type::Item) and ("No." <> '') then
                GetUnitCost();

            CheckWMS();

            if "Document Type" = "Document Type"::"Return Order" then
                ValidateReturnReasonCode(FieldNo("Location Code"));

            CreateDimFromDefaultDim(Rec.FieldNo("Location Code"));

            OnAfterValidateLocationCode(Rec, xRec);
        end;
    }

VladimirTkalich avatar Mar 14 '23 16:03 VladimirTkalich

@AlexanderYakunin Hello. Have you had a chance to review this request? Are there any updates on this?

NadiiaMelnyk-BC avatar Jun 06 '23 08:06 NadiiaMelnyk-BC

Why do you need new event OnValidateLocationCodeValidateShortcutDimension1Code after procedure AutoAsmToOrder? Can't you use OnValidateLocationCodeOnAfterSetOutboundWhseHandlingTime for your scenario?

Also looks like name of your event missleading from is the purpose of publisher that you request.

tomasevics avatar Jun 14 '23 10:06 tomasevics

Hi, thank you for the response. I double-checked all possible scenarios if we move the code to the OnValidateLocationCodeOnAfterSetOutboundWhseHandlingTime event. It seems that it should work. The request can be closed as "Not needed"

VladimirTkalich avatar Jun 15 '23 14:06 VladimirTkalich