Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -784,7 +784,7 @@ codeunit 20404 "Qlty. Inspection - Create"
end;

/// <summary>
/// Use this to log QIERR0001
/// Use this to log QMERR0001
/// </summary>
/// <param name="ContextRecordRef"></param>
/// <param name="Input"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// We subscribe to OnAfterPostOutput to see if we need to create an inspection related to the output.
Expand Down Expand Up @@ -184,67 +180,51 @@ codeunit 20407 "Qlty. Manufactur. Integration"
/// </summary>
/// <param name="OldProductionOrder"></param>
/// <param name="NewProductionOrder"></param>
[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;

/// <summary>
/// Updates inspections where the source is a production order line
/// </summary>
/// <param name="OldProdOrderLine"></param>
/// <param name="NewProdOrderLine"></param>
[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
Expand Down Expand Up @@ -276,19 +256,16 @@ codeunit 20407 "Qlty. Manufactur. Integration"
/// </summary>
/// <param name="OldProdOrderRoutingLine"></param>
/// <param name="NewProdOrderRoutingLine"></param>
[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());
Expand Down Expand Up @@ -515,30 +492,6 @@ codeunit 20407 "Qlty. Manufactur. Integration"
OnAfterProductionAttemptCreateAutomaticInspection(ProdOrderRoutingLine, ItemLedgerEntry, ProdOrderLine, ItemJournalLine);
end;

/// <summary>
/// Use this to log QMERR0002
/// </summary>
/// <param name="ContextVariant"></param>
/// <param name="Input"></param>
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;

/// <summary>
/// OnBeforeProductionAttemptCreatePostAutomaticInspection is called before attempting to automatically create an inspection for production related events prior to posting to posting.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
Loading