Skip to content

[W1][Report][87][Copy - General Posting Setup] Add integration event OnAfterConfirmAndModify in the General Posting Setup dataitem OnAfterGetRecord trigger after Modify. #30120

@mavohra

Description

@mavohra

Why do you need this change?

We need to run ExtraChargeMgmt.CopyPostingSetup immediately after Modify() is called inside the user confirmation block in the General Posting Setup dataitem OnAfterGetRecord trigger of Report "Copy Gen. Posting Setup". The standard code only calls Modify() when the user confirms, but our custom logic requires ExtraChargeMgmt.CopyPostingSetup to run in the same confirmation scope — it should only execute when the user clicks Yes, never outside of it.

OnAfterCopyGenPostingSetup fires before the confirmation check and before Modify() — so a subscriber there cannot conditionally run logic based on user confirmation. The report extension OnAfterGetRecord trigger runs after the entire base trigger completes, meaning it runs outside the confirmation block and would execute regardless of what the user chose. No event currently exists inside the confirmation block after Modify() in Report "Copy Gen. Posting Setup".

Describe the request

Add an integration event OnAfterConfirmAndModify in the General Posting Setup dataitem OnAfterGetRecord trigger of Report "Copy Gen. Posting Setup" immediately after Modify() inside the confirmation block.

trigger OnAfterGetRecord()
            var
                ConfirmManagement: Codeunit "Confirm Management";
            begin
                GenPostingSetup.Find();
                if CopySales then begin
                    "Sales Account" := GenPostingSetup."Sales Account";
                    "Sales Credit Memo Account" := GenPostingSetup."Sales Credit Memo Account";
                    "Sales Line Disc. Account" := GenPostingSetup."Sales Line Disc. Account";
                    "Sales Inv. Disc. Account" := GenPostingSetup."Sales Inv. Disc. Account";
                    "Sales Pmt. Disc. Debit Acc." := GenPostingSetup."Sales Pmt. Disc. Debit Acc.";
                    "Sales Pmt. Disc. Credit Acc." := GenPostingSetup."Sales Pmt. Disc. Credit Acc.";
                    "Sales Pmt. Tol. Debit Acc." := GenPostingSetup."Sales Pmt. Tol. Debit Acc.";
                    "Sales Pmt. Tol. Credit Acc." := GenPostingSetup."Sales Pmt. Tol. Credit Acc.";
                    "Sales Prepayments Account" := GenPostingSetup."Sales Prepayments Account";
                end;

                if CopyPurchases then begin
                    "Purch. Account" := GenPostingSetup."Purch. Account";
                    "Purch. Credit Memo Account" := GenPostingSetup."Purch. Credit Memo Account";
                    "Purch. Line Disc. Account" := GenPostingSetup."Purch. Line Disc. Account";
                    "Purch. Inv. Disc. Account" := GenPostingSetup."Purch. Inv. Disc. Account";
                    "Purch. Pmt. Disc. Debit Acc." := GenPostingSetup."Purch. Pmt. Disc. Debit Acc.";
                    "Purch. Pmt. Disc. Credit Acc." := GenPostingSetup."Purch. Pmt. Disc. Credit Acc.";
                    "Purch. FA Disc. Account" := GenPostingSetup."Purch. FA Disc. Account";
                    "Purch. Pmt. Tol. Debit Acc." := GenPostingSetup."Purch. Pmt. Tol. Debit Acc.";
                    "Purch. Pmt. Tol. Credit Acc." := GenPostingSetup."Purch. Pmt. Tol. Credit Acc.";
                    "Purch. Prepayments Account" := GenPostingSetup."Purch. Prepayments Account";
                end;

                if CopyInventory then begin
                    "COGS Account" := GenPostingSetup."COGS Account";
                    "COGS Account (Interim)" := GenPostingSetup."COGS Account (Interim)";
                    "Inventory Adjmt. Account" := GenPostingSetup."Inventory Adjmt. Account";
                    "Invt. Accrual Acc. (Interim)" := GenPostingSetup."Invt. Accrual Acc. (Interim)";
                end;

                if CopyManufacturing then begin
                    "Direct Cost Applied Account" := GenPostingSetup."Direct Cost Applied Account";
                    "Overhead Applied Account" := GenPostingSetup."Overhead Applied Account";
                    "Purchase Variance Account" := GenPostingSetup."Purchase Variance Account";
                end;

                OnAfterCopyGenPostingSetup("General Posting Setup", GenPostingSetup, CopySales, CopyPurchases, CopyInventory, CopyManufacturing);

                if ConfirmManagement.GetResponseOrDefault(Text000, true) then
                    Modify();
                    OnAfterConfirmAndModify("General Posting Setup", GenPostingSetup);
            end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnAfterConfirmAndModify(var ToGeneralPostingSetup: Record "General Posting Setup"; FromGeneralPostingSetup: Record "General Posting Setup")
begin
end;

Alternatives evaluated:
OnAfterCopyGenPostingSetup fires before the confirmation check and before Modify(), so a subscriber there cannot replicate logic that must only run when the user confirms. The report extension OnAfterGetRecord trigger runs after the full base trigger completes outside the confirmation block so it cannot conditionally execute based on user confirmation. No event currently exists inside the confirmation block after Modify() in Report "Copy Gen. Posting Setup".

Metadata

Metadata

Assignees

No one assigned

    Labels

    FinanceGitHub request for Finance areaevent-requestRequest for adding an event

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions