ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

table 39 "Purchase Line" - OnValidateNoAfterCopyFromTempPurchLineOnBeforeInitRec

Open domingosbarreto opened this issue 2 years ago • 2 comments

Describe the request

Can you please add the following event to table 39 "Purchase Line"?

Old code:

        field(6; "No."; Code[20])
        {
            CaptionClass = GetCaptionClass(FieldNo("No."));
            Caption = 'No.';
            TableRelation = if (Type = const(" ")) "Standard Text"
            else
            if (Type = const("G/L Account"), "System-Created Entry" = const(false)) "G/L Account" where("Direct Posting" = const(true), "Account Type" = const(Posting), Blocked = const(false))
            else
            if (Type = const("G/L Account"), "System-Created Entry" = const(true)) "G/L Account"
            else
            if (Type = const("Fixed Asset")) "Fixed Asset"
            else
            if (Type = const("Charge (Item)")) "Item Charge"
            else
            if (Type = const(Item), "Document Type" = filter(<> "Credit Memo" & <> "Return Order")) Item where(Blocked = const(false), "Purchasing Blocked" = const(false))
            else
            if (Type = const(Item), "Document Type" = filter("Credit Memo" | "Return Order")) Item where(Blocked = const(false))
            else
            if (Type = const("Allocation Account")) "Allocation Account"
            else
            if (Type = const(Resource)) Resource;

            ValidateTableRelation = false;

            trigger OnValidate()
            var
                TempPurchLine: Record "Purchase Line" temporary;
                IsHandled: Boolean;
            begin
                
                [...]
                
                OnValidateNoOnBeforeInitRec(Rec, xRec, CurrFieldNo);
                TempPurchLine := Rec;
                Init();
                SystemId := TempPurchLine.SystemId;

                [...]
                
            end;
        }

New code:

        field(6; "No."; Code[20])
        {
            CaptionClass = GetCaptionClass(FieldNo("No."));
            Caption = 'No.';
            TableRelation = if (Type = const(" ")) "Standard Text"
            else
            if (Type = const("G/L Account"), "System-Created Entry" = const(false)) "G/L Account" where("Direct Posting" = const(true), "Account Type" = const(Posting), Blocked = const(false))
            else
            if (Type = const("G/L Account"), "System-Created Entry" = const(true)) "G/L Account"
            else
            if (Type = const("Fixed Asset")) "Fixed Asset"
            else
            if (Type = const("Charge (Item)")) "Item Charge"
            else
            if (Type = const(Item), "Document Type" = filter(<> "Credit Memo" & <> "Return Order")) Item where(Blocked = const(false), "Purchasing Blocked" = const(false))
            else
            if (Type = const(Item), "Document Type" = filter("Credit Memo" | "Return Order")) Item where(Blocked = const(false))
            else
            if (Type = const("Allocation Account")) "Allocation Account"
            else
            if (Type = const(Resource)) Resource;

            ValidateTableRelation = false;

            trigger OnValidate()
            var
                TempPurchLine: Record "Purchase Line" temporary;
                IsHandled: Boolean;
            begin
                
                [...]
                
                OnValidateNoOnBeforeInitRec(Rec, xRec, CurrFieldNo);
                TempPurchLine := Rec;
                OnValidateNoAfterCopyFromTempPurchLineOnBeforeInitRec(Rec, IsHandled);
                if not IsHandled then
                    Init();
                SystemId := TempPurchLine.SystemId;

                [...]
                
            end;
        }

    [IntegrationEvent(false, false)]
    local procedure OnValidateNoAfterCopyFromTempPurchLineOnBeforeInitRec(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
    begin
    end;

Additional context

In some cases there is the need to stop the record initialization. Internal work item: AB#496081

domingosbarreto avatar Jan 08 '24 14:01 domingosbarreto

Can you please explain why do you need to skip Init() here?

AlexanderYakunin avatar Jan 16 '24 18:01 AlexanderYakunin

Closed due to inactivity.

tomasevicst avatar Apr 08 '24 12:04 tomasevicst