From 178dcde125391c05e32cd544a5ded938d127abef Mon Sep 17 00:00:00 2001
From: Dusan Jakovljevic <134404137+JakovljevicDusan@users.noreply.github.com>
Date: Thu, 5 Feb 2026 16:31:54 +0100
Subject: [PATCH 1/2] [Quality Management] Improve handling updating Quality
Inspections on Manufacturing action
---
.../Document/QltyInspectionCreate.Codeunit.al | 6 +-
.../QltyManufacturIntegration.Codeunit.al | 93 +++++--------------
2 files changed, 26 insertions(+), 73 deletions(-)
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 a0fe807d01..f024023ee9 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
@@ -37,11 +37,11 @@ codeunit 20404 "Qlty. Inspection - Create"
PreventShowingGeneratedInspectionEvenIfConfigured: Boolean;
AvoidThrowingErrorWhenPossible: Boolean;
ProgrammerErrNotARecordRefErr: Label 'Cannot find inspections with %1. Please supply a "Record" or "RecordRef".', Comment = '%1=the variant being supplied that is not a RecordRef. Your system might have an extension or customization that needs to be re-configured.';
- CannotFindTemplateErr: Label 'Cannot find a Quality Inspection Template or Quality Inspection Generation Rule to match %1. Ensure there is a Quality Inspection Generation Rule that will match this record.', Comment = '%1=The record identifier';
+ CannotFindTemplateErr: Label 'Cannot find a Quality Inspection Template or Quality Inspection Generation Rule to match %1. Ensure there is a Quality Inspection Generation Rule that will match this record.', Comment = '%1=The record identifier';
UnableToCreateInspectionForErr: Label 'Unable to create an inspection for the record [%1], please review the Quality Inspection Source Configuration and also the Quality Inspection Generation Rules, you likely need additional configuration to work with this record.', Comment = '%1=the record id of what is being attempted to have an inspection created for.';
NoSpecificTemplateTok: Label '', Locked = true;
MultiRecordInspectionSourceFieldErr: Label 'Inspection %1 has been created, however neither %2 nor %4 had applicable source fields to map to the inspection. Navigate to the Quality Source Configuration for table %3 and apply source field mapping.', Comment = '%1=the inspection, %2=target record, %3=the number to set configuration for,%4=triggering record';
- RegisteredLogEventIDTok: Label 'QIERR0001', Locked = true;
+ RegisteredLogEventIDTok: Label 'QMERR0001', Locked = true;
DetailRecordTok: Label 'Target', Locked = true;
UnableToCreateInspectionForParentOrChildErr: Label 'Cannot find enough details to make an inspection for your record(s). Try making sure that there is a source configuration for your record, and then also make sure there is sufficient information in your inspection generation rules. Two tables involved are %1 and %2.', Comment = '%1=the parent table, %2=the child and original table.';
UnableToCreateInspectionForRecordErr: Label 'Cannot find enough details to make an inspection for your record(s). Try making sure that there is a source configuration for your record, and then also make sure there is sufficient information in your inspection generation rules. The table involved is %1.', Comment = '%1=the table involved.';
@@ -784,7 +784,7 @@ codeunit 20404 "Qlty. Inspection - Create"
end;
///
- /// Use this to log QIERR0001
+ /// Use this to log QMERR0001
///
///
///
diff --git a/src/Apps/W1/Quality Management/app/src/Integration/Manufacturing/QltyManufacturIntegration.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Integration/Manufacturing/QltyManufacturIntegration.Codeunit.al
index db4fe90c05..63dd0dea28 100644
--- a/src/Apps/W1/Quality Management/app/src/Integration/Manufacturing/QltyManufacturIntegration.Codeunit.al
+++ b/src/Apps/W1/Quality Management/app/src/Integration/Manufacturing/QltyManufacturIntegration.Codeunit.al
@@ -23,10 +23,6 @@ codeunit 20407 "Qlty. Manufactur. Integration"
var
QltyTraversal: Codeunit "Qlty. Traversal";
QltySessionHelper: Codeunit "Qlty. Session Helper";
- PermissionErr: Label 'User %1 not have permission to modify Quality Inspection Results tables, this will prevent inspection being updated.', Comment = '%1:User ID';
- ProductionRegisteredLogEventIDTok: Label 'QMERR0002', Locked = true;
- TargetDetailRecordTok: Label 'Target', Locked = true;
- UnknownRecordTok: Label 'Unknown record', Locked = true;
///
/// We subscribe to OnAfterPostOutput to see if we need to create an inspection related to the output.
@@ -184,50 +180,37 @@ codeunit 20407 "Qlty. Manufactur. Integration"
///
///
///
+ [InherentPermissions(PermissionObjectType::TableData, Database::"Qlty. Inspection Header", 'rm')]
local procedure UpdateReferencesForProductionOrder(OldProductionOrder: Record "Production Order"; NewProductionOrder: Record "Production Order")
var
QltyInspectionHeader: Record "Qlty. Inspection Header";
TargetRecordRef: RecordRef;
begin
TargetRecordRef.GetTable(NewProductionOrder);
- if not QltyInspectionHeader.WritePermission() then begin
- LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
- exit;
- end;
+ // Use filter groups to find records where any of the Source RecordId fields match
+ QltyInspectionHeader.FilterGroup(-1); // Cross-column filtering
QltyInspectionHeader.SetRange("Source RecordId", OldProductionOrder.RecordId());
+ QltyInspectionHeader.SetRange("Source RecordId 2", OldProductionOrder.RecordId());
+ QltyInspectionHeader.SetRange("Source RecordId 3", OldProductionOrder.RecordId());
+ QltyInspectionHeader.SetRange("Source RecordId 4", OldProductionOrder.RecordId());
+ QltyInspectionHeader.FilterGroup(0);
+
if QltyInspectionHeader.FindSet(true) then
repeat
- QltyInspectionHeader."Source RecordId" := NewProductionOrder.RecordId();
+ if QltyInspectionHeader."Source RecordId" = OldProductionOrder.RecordId() then
+ QltyInspectionHeader."Source RecordId" := NewProductionOrder.RecordId()
+ else
+ if QltyInspectionHeader."Source RecordId 2" = OldProductionOrder.RecordId() then
+ QltyInspectionHeader."Source RecordId 2" := NewProductionOrder.RecordId()
+ else
+ if QltyInspectionHeader."Source RecordId 3" = OldProductionOrder.RecordId() then
+ QltyInspectionHeader."Source RecordId 3" := NewProductionOrder.RecordId()
+ else
+ if QltyInspectionHeader."Source RecordId 4" = OldProductionOrder.RecordId() then
+ QltyInspectionHeader."Source RecordId 4" := NewProductionOrder.RecordId();
UpdateSourceDocumentForSpecificInspectionOnOrder(QltyInspectionHeader, TargetRecordRef, OldProductionOrder, NewProductionOrder);
- until QltyInspectionHeader.Next() = 0
- else begin
- QltyInspectionHeader.Reset();
- QltyInspectionHeader.SetRange("Source RecordId 2", OldProductionOrder.RecordId());
- if QltyInspectionHeader.FindSet(true) then
- repeat
- QltyInspectionHeader."Source RecordId 2" := NewProductionOrder.RecordId();
- UpdateSourceDocumentForSpecificInspectionOnOrder(QltyInspectionHeader, TargetRecordRef, OldProductionOrder, NewProductionOrder);
- until QltyInspectionHeader.Next() = 0
- else begin
- QltyInspectionHeader.Reset();
- QltyInspectionHeader.SetRange("Source RecordId 3", OldProductionOrder.RecordId());
- if QltyInspectionHeader.FindSet(true) then
- repeat
- QltyInspectionHeader."Source RecordId 3" := NewProductionOrder.RecordId();
- UpdateSourceDocumentForSpecificInspectionOnOrder(QltyInspectionHeader, TargetRecordRef, OldProductionOrder, NewProductionOrder);
- until QltyInspectionHeader.Next() = 0
- else begin
- QltyInspectionHeader.Reset();
- QltyInspectionHeader.SetRange("Source RecordId 4", OldProductionOrder.RecordId());
- if QltyInspectionHeader.FindSet(true) then
- repeat
- QltyInspectionHeader."Source RecordId 4" := NewProductionOrder.RecordId();
- UpdateSourceDocumentForSpecificInspectionOnOrder(QltyInspectionHeader, TargetRecordRef, OldProductionOrder, NewProductionOrder);
- until QltyInspectionHeader.Next() = 0;
- end;
- end;
- end;
+ until QltyInspectionHeader.Next() = 0;
end;
///
@@ -235,16 +218,13 @@ codeunit 20407 "Qlty. Manufactur. Integration"
///
///
///
+ [InherentPermissions(PermissionObjectType::TableData, Database::"Qlty. Inspection Header", 'rm')]
local procedure UpdateReferencesForProductionOrderLine(OldProdOrderLine: Record "Prod. Order Line"; NewProdOrderLine: Record "Prod. Order Line")
var
QltyInspectionHeader: Record "Qlty. Inspection Header";
TargetRecordRef: RecordRef;
begin
TargetRecordRef.GetTable(NewProdOrderLine);
- if not QltyInspectionHeader.WritePermission() then begin
- LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
- exit;
- end;
// Use filter groups to find records where any of the Source RecordId fields match
QltyInspectionHeader.FilterGroup(-1); // Cross-column filtering
@@ -276,19 +256,16 @@ codeunit 20407 "Qlty. Manufactur. Integration"
///
///
///
+ [InherentPermissions(PermissionObjectType::TableData, Database::"Qlty. Inspection Header", 'rm')]
local procedure UpdateReferencesForProductionOrderRoutingLine(OldProdOrderRoutingLine: Record "Prod. Order Routing Line"; NewProdOrderRoutingLine: Record "Prod. Order Routing Line")
var
QltyInspectionHeader: Record "Qlty. Inspection Header";
TargetRecordRef: RecordRef;
begin
TargetRecordRef.GetTable(NewProdOrderRoutingLine);
- if not QltyInspectionHeader.WritePermission() then begin
- LogProductionProblemWith1(TargetRecordRef, PermissionErr, UserId());
- exit;
- end;
// Use filter groups to find records where any of the Source RecordId fields match
- QltyInspectionHeader.FilterGroup(-1); // OR filtering
+ QltyInspectionHeader.FilterGroup(-1); // Cross-column filtering
QltyInspectionHeader.SetRange("Source RecordId", OldProdOrderRoutingLine.RecordId());
QltyInspectionHeader.SetRange("Source RecordId 2", OldProdOrderRoutingLine.RecordId());
QltyInspectionHeader.SetRange("Source RecordId 3", OldProdOrderRoutingLine.RecordId());
@@ -515,30 +492,6 @@ codeunit 20407 "Qlty. Manufactur. Integration"
OnAfterProductionAttemptCreateAutomaticInspection(ProdOrderRoutingLine, ItemLedgerEntry, ProdOrderLine, ItemJournalLine);
end;
- ///
- /// Use this to log QMERR0002
- ///
- ///
- ///
- local procedure LogProductionProblem(ContextVariant: Variant; Input: Text)
- var
- QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
- ContextRecordRef: RecordRef;
- DetailRecord: Text;
- begin
- if QltyMiscHelpers.GetRecordRefFromVariant(ContextVariant, ContextRecordRef) then
- DetailRecord := Format(ContextRecordRef.RecordId())
- else
- DetailRecord := UnknownRecordTok;
-
- LogMessage(ProductionRegisteredLogEventIDTok, Input, Verbosity::Error, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, TargetDetailRecordTok, DetailRecord);
- end;
-
- local procedure LogProductionProblemWith1(ContextVariant: Variant; Input: Text; Variable1: Text)
- begin
- LogProductionProblem(ContextVariant, StrSubstNo(Input, Variable1));
- end;
-
///
/// OnBeforeProductionAttemptCreatePostAutomaticInspection is called before attempting to automatically create an inspection for production related events prior to posting to posting.
///
From 12181cdd8c68d0732df55543d3afd2c5bf1f4756 Mon Sep 17 00:00:00 2001
From: Dusan Jakovljevic <134404137+JakovljevicDusan@users.noreply.github.com>
Date: Mon, 9 Feb 2026 15:28:14 +0100
Subject: [PATCH 2/2] Test fix
---
.../test/src/QltyTestsCreateInspect.Codeunit.al | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Apps/W1/Quality Management/test/src/QltyTestsCreateInspect.Codeunit.al b/src/Apps/W1/Quality Management/test/src/QltyTestsCreateInspect.Codeunit.al
index d5279bed30..20b4aa8481 100644
--- a/src/Apps/W1/Quality Management/test/src/QltyTestsCreateInspect.Codeunit.al
+++ b/src/Apps/W1/Quality Management/test/src/QltyTestsCreateInspect.Codeunit.al
@@ -32,7 +32,7 @@ codeunit 139959 "Qlty. Tests - Create Inspect."
LibraryERMCountryData: Codeunit "Library - ERM Country Data";
QltyInspectionCreate: Codeunit "Qlty. Inspection - Create";
QltyInspectionUtility: Codeunit "Qlty. Inspection Utility";
- CannotFindTemplateErr: Label 'Cannot find a Quality Inspection Template or Quality Inspection Generation Rule to match %1. Ensure there is a Quality Inspection Generation Rule that will match this record.', Comment = '%1=The record identifier';
+ CannotFindTemplateErr: Label 'Cannot find a Quality Inspection Template or Quality Inspection Generation Rule to match %1. Ensure there is a Quality Inspection Generation Rule that will match this record.', Comment = '%1=The record identifier';
ProgrammerErrNotARecordRefErr: Label 'Cannot find inspections with %1. Please supply a "Record" or "RecordRef".', Comment = '%1=the variant being supplied that is not a RecordRef. Your system might have an extension or customization that needs to be re-configured.';
UnableToCreateInspectionForRecordErr: Label 'Cannot find enough details to make an inspection for your record(s). Try making sure that there is a source configuration for your record, and then also make sure there is sufficient information in your inspection generation rules. The table involved is %1.', Comment = '%1=the table involved.';
UnableToCreateInspectionForParentOrChildErr: Label 'Cannot find enough details to make an inspection for your record(s). Try making sure that there is a source configuration for your record, and then also make sure there is sufficient information in your inspection generation rules. Two tables involved are %1 and %2.', Comment = '%1=the parent table, %2=the child and original table.';