From 85555589a79e4702fb2a6be58269bdeb6a2e8aad Mon Sep 17 00:00:00 2001
From: "business-central-extensibility-bot[bot]"
<324022251+business-central-extensibility-bot[bot]@users.noreply.github.com>
Date: Thu, 10 Sep 2026 07:57:57 +0000
Subject: [PATCH] [Extensibility Request] issue 10929: add inspection line
insert event (#11166)
## Summary
Extensions need to initialize custom fields on each quality inspection
line from its corresponding template line before the new line is
inserted. This change adds a per-line integration event at that point in
the template-driven creation flow, giving subscribers access to both
records.
## Changes Made
- `CreateQualityInspectionResultLinesFromTemplate` - raises a new event
immediately before each quality inspection line is inserted so
extensions can copy and validate line-specific values from the source
template line
Fixes #10929
> [!IMPORTANT]
> AI-generated: content may be inaccurate or incomplete. Please review
and verify before relying on or merging.
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JakovljevicDusan <134404137+JakovljevicDusan@users.noreply.github.com>
(cherry picked from commit 1da0e3dccc4780fe929eb380911b92f7593f8e81)
---
.../src/Document/QltyInspectionCreate.Codeunit.al | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/Apps/W1/Quality Management/app/src/Document/QltyInspectionCreate.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Document/QltyInspectionCreate.Codeunit.al
index 465bf85d39c..5b8879f63cc 100644
--- a/src/Apps/W1/Quality Management/app/src/Document/QltyInspectionCreate.Codeunit.al
+++ b/src/Apps/W1/Quality Management/app/src/Document/QltyInspectionCreate.Codeunit.al
@@ -658,6 +658,7 @@ codeunit 20404 "Qlty. Inspection - Create"
/// Creates inspection lines and result conditions from the header's template and evaluates the new lines.
///
/// The inspection for which to create lines.
+ [CommitBehavior(CommitBehavior::Ignore)]
local procedure CreateQualityInspectionResultLinesFromTemplate(var QltyInspectionHeader: Record "Qlty. Inspection Header")
var
QltyInspectionTemplateLine: Record "Qlty. Inspection Template Line";
@@ -680,6 +681,7 @@ codeunit 20404 "Qlty. Inspection - Create"
QltyInspectionLine.Description := QltyInspectionTemplateLine.Description;
QltyInspectionLine."Allowable Values" := QltyInspectionTemplateLine."Allowable Values";
QltyInspectionLine."Unit of Measure Code" := QltyInspectionTemplateLine."Unit of Measure Code";
+ OnCreateQualityInspectionResultLinesFromTemplateOnBeforeInsertQltyInspectionLine(QltyInspectionLine, QltyInspectionTemplateLine);
QltyInspectionLine.Insert();
QltyResultConditionMgmt.CopyResultConditionsFromTemplateToInspection(QltyInspectionTemplateLine, QltyInspectionLine);
QltyInspectionHeader.SetPreventAutoAssignment(true);
@@ -1264,6 +1266,16 @@ codeunit 20404 "Qlty. Inspection - Create"
#endregion Event Subscribers
+ ///
+ /// Raised before a quality inspection line created from a template line is inserted.
+ ///
+ /// The quality inspection line to be inserted.
+ /// The source quality inspection template line.
+ [IntegrationEvent(false, false)]
+ local procedure OnCreateQualityInspectionResultLinesFromTemplateOnBeforeInsertQltyInspectionLine(var QltyInspectionLine: Record "Qlty. Inspection Line"; QltyInspectionTemplateLine: Record "Qlty. Inspection Template Line")
+ begin
+ end;
+
///
/// OnBeforeCreateInspection is called before an inspection is created.
/// Use this event to do additional checks before an inspection is created.