Skip to content

table 39 "Purchase Line" field 74 "Gen. Bus. Posting Group" trigger OnValidate new integration event OnBeforeValidateVATBusPostingGroup #29581

@viktorijakot

Description

@viktorijakot

Why do you need this change?

In 4PS Construct, we need to conditionally bypass the automatic VAT Bus. Posting Group validation in the Purchase Line table when the Gen. Bus. Posting Group changes. The original code unconditionally validates and updates the VAT Bus. Posting Group whenever the Gen. Bus. Posting Group is modified. However, for specific business scenarios in our construction management workflows - such as when using extended VAT determination logic, importing purchase data from external systems, or handling multi-country VAT scenarios - we need to prevent this automatic update and manage VAT posting groups through our own custom logic. By introducing the OnBeforeValidateVATBusPostingGroup integration event, we can control whether the VAT validation is performed, allowing extensions to set a flag to skip it when appropriate. This enables more flexible VAT handling for international projects without requiring core code modifications.

Alternatives Evaluated
Other events in the Purchase Line validation chain are insufficient because they execute after the VAT Bus. Posting Group has already been updated, making it impossible to prevent the change. We also considered overriding the VAT Bus. Posting Group field directly in extensions, but this would require duplicating the entire Gen. Bus. Posting Group validation logic and would conflict with other standard functionality that depends on this field relationship.

Justification for IsHandled Pattern
Bypassing the VAT validation is necessary because our business scenarios require complete control over VAT determination without relying on the default posting group relationships.
A standard event that only allows modification of values after validation would not suffice, as the system would still attempt to validate and update the VAT Bus. Posting Group based on the default relationship defined in the Gen. Business Posting Group setup. The ValidateVATBusPostingGroup boolean bypass provides the precise control needed to skip the validation entirely when our custom logic has already determined the appropriate VAT posting group, enabling specialized VAT handling without workarounds or performance-heavy post-validation corrections.

Performance Considerations
This event is placed at the start of the Gen. Bus. Posting Group field validation trigger, which is invoked when users change the posting group on purchase documents or when programmatic updates occur during document processing. In typical 4PS Construct usage scenarios (purchase order entry, invoice processing, and estimate conversion), this validation may run multiple times per document. However, the event is lightweight: it initializes a single boolean variable and makes one event call with minimal parameters (the Purchase Line record and a boolean reference). We expect negligible performance impact, as the event allows early exit from validation logic when appropriate, potentially improving performance in scenarios where the extended VAT determination is used.

Data Sensitivity Review
Confirming that bypassing this validation does not expose sensitive data or create security risks: The change allows conditional skipping of the automatic VAT Bus. Posting Group update, but does not alter data access controls, user permissions, or audit trails. The validation being bypassed is a business-rule automation (updating VAT posting group based on Gen. Bus. Posting Group relationship), not a security-related validation. VAT-related financial data remains protected by existing mechanisms such as posting group permissions, document approval workflows, and audit logging. Extensions subscribing to this event must implement their own validation logic to ensure VAT posting groups are set correctly according to local tax regulations. The bypass itself poses no inherent security risk, as users with permission to modify Gen. Bus. Posting Group already have permission to modify VAT Bus. Posting Group directly.

Multi-Extension Interaction
If multiple extensions subscribe to this event, there is a risk of conflicts if they attempt to set ValidateVATBusPostingGroup to different values (e.g., one extension sets it to false to bypass, while another expects true for standard validation). This could lead to inconsistent VAT determination behavior. To mitigate:

  • Extensions should check the General Ledger Setup for "Extended Purch. VAT Determ." or similar custom flags before modifying the boolean parameter

  • Use conditional logic to only bypass when specific criteria are met (e.g., specific document types, vendor types, or project configurations)

  • Document the extension's behavior clearly so administrators can identify potential conflicts

  • Consider using event subscriber execution order attributes if supported by the platform

In 4PS Construct, we set ValidateVATBusPostingGroup to false only when "Extended Purch. VAT Determ." is enabled in General Ledger Setup, ensuring our bypass is controlled by a clear system-wide setting. If conflicts arise, they can be resolved through extension configuration or by adjusting the priority of event subscribers.

Describe the request

Dear ALAppExtensions team,

On behalf of 4PS, I would like to request the addition of a new integration event in the Purchase Line table (Table 39): OnBeforeValidateVATBusPostingGroup.

We need it to be triggered at the start of the OnValidate trigger for the "Gen. Bus. Posting Group" field (Field 74), allowing extensions to modify a ValidateVATBusPostingGroup Boolean parameter to conditionally skip the subsequent VAT Bus. Posting Group validation and update logic.

Current code:

trigger OnValidate()
begin
if xRec."Gen. Bus. Posting Group" <> "Gen. Bus. Posting Group" then
if GenBusPostingGrp.ValidateVatBusPostingGroup(GenBusPostingGrp, "Gen. Bus. Posting Group") then
Validate("VAT Bus. Posting Group", GenBusPostingGrp."Def. VAT Bus. Posting Group");
end;

Suggested extensibility:

trigger OnValidate()
var
ValidateVATBusPostingGroup: Boolean;
begin
ValidateVATBusPostingGroup := xRec."Gen. Bus. Posting Group" <> "Gen. Bus. Posting Group";
OnBeforeValidateVATBusPostingGroup(Rec, ValidateVATBusPostingGroup);
if ValidateVATBusPostingGroup then begin
if GenBusPostingGrp.ValidateVatBusPostingGroup(GenBusPostingGrp, "Gen. Bus. Posting Group") then
Validate("VAT Bus. Posting Group", GenBusPostingGrp."Def. VAT Bus. Posting Group");
end;
end;

This extensibility enables 4PS Construct to implement advanced VAT determination logic for international construction projects while maintaining compatibility with standard Business Central functionality.

Internal work item: AB#618044

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions