From 65dcc8177afbab8442f1613d7c0794e60a28039e Mon Sep 17 00:00:00 2001 From: aldobriansky Date: Thu, 19 Feb 2026 16:58:59 +0100 Subject: [PATCH 1/3] Enable item ledger entry inspection --- .../JobQueue/QltyScheduleInspection.Report.al | 11 +-- .../QltyAutoConfigure.Codeunit.al | 72 +++++++++++++++++++ .../Document/QltyCreateInspection.Report.al | 7 +- 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al index 39157c71ad..459bc53920 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al @@ -23,7 +23,7 @@ report 20412 "Qlty. Schedule Inspection" dataitem(CurrentInspectionGenerationRule; "Qlty. Inspection Gen. Rule") { RequestFilterFields = "Schedule Group", "Template Code", Description; - DataItemTableView = where("Activation Trigger" = filter(<> Disabled), "Schedule Group" = filter(<> '')); + DataItemTableView = where("Activation Trigger" = filter(<> Disabled)); trigger OnAfterGetRecord() begin @@ -32,8 +32,6 @@ report 20412 "Qlty. Schedule Inspection" trigger OnPreDataItem() begin - if CurrentInspectionGenerationRule.GetFilter("Schedule Group") = '' then - Error(ScheduleGroupIsMandatoryErr); end; } } @@ -73,7 +71,6 @@ report 20412 "Qlty. Schedule Inspection" CreatedQltyInspectionIds: List of [Code[20]]; ZeroInspectionsCreatedMsg: Label 'No inspections were created.'; SomeInspectionsWereCreatedQst: Label '%1 inspections were created. Do you want to see them?', Comment = '%1=the count of inspections that were created.'; - ScheduleGroupIsMandatoryErr: Label 'It is mandatory to define a schedule group on the inspection generation rule(s), and then configure the schedule with the same group. This will help make sure that inadvertent configuration does not cause excessive inspection generation.'; trigger OnInitReport() begin @@ -110,9 +107,6 @@ report 20412 "Qlty. Schedule Inspection" if QltyInspectionGenRule."Activation Trigger" = QltyInspectionGenRule."Activation Trigger"::Disabled then exit; - if QltyInspectionGenRule."Schedule Group" = '' then - exit; - QltyJobQueueManagement.CheckIfGenerationRuleCanBeScheduled(QltyInspectionGenRule); SourceRecordRef.Open(QltyInspectionGenRule."Source Table No."); @@ -120,7 +114,8 @@ report 20412 "Qlty. Schedule Inspection" SourceRecordRef.SetView(QltyInspectionGenRule."Condition Filter"); QltyInspectionGenRule.SetRecFilter(); - QltyInspectionGenRule.SetRange("Schedule Group", QltyInspectionGenRule."Schedule Group"); + if QltyInspectionGenRule."Schedule Group" <> '' then + QltyInspectionGenRule.SetRange("Schedule Group", QltyInspectionGenRule."Schedule Group"); QltyInspectionGenRule.SetRange("Template Code", QltyInspectionGenRule."Template Code"); if SourceRecordRef.FindSet() then QltyInspectionCreate.CreateMultipleInspectionsWithoutDisplaying(SourceRecordRef, GuiAllowed(), QltyInspectionGenRule, CreatedQltyInspectionIds); diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/QltyAutoConfigure.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Configuration/QltyAutoConfigure.Codeunit.al index 2f73547634..010bd4d2f9 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/QltyAutoConfigure.Codeunit.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/QltyAutoConfigure.Codeunit.al @@ -90,6 +90,8 @@ codeunit 20402 "Qlty. Auto Configure" ProdRoutingToInspectDescriptionTxt: Label 'Prod. Order Routing Line to Inspection', MaxLength = 100; AssemblyOutputToInspectTok: Label 'ASMOUTPUTTOINSPECT', MaxLength = 20, Locked = true; AssemblyOutputToInspectDescriptionTxt: Label 'Posted Assembly Header to Inspection', MaxLength = 100; + OpenLedgerToInspectTok: Label 'ITEMLDGROPENINSPECT', MaxLength = 20, Locked = true; + OpenLedgerToInspectDescriptionTxt: Label 'Open Item Ledger Entry to Inspection', MaxLength = 100; internal procedure GetDefaultPassResult(): Text begin @@ -242,6 +244,7 @@ codeunit 20402 "Qlty. Auto Configure" CreateDefaultProductionAndAssemblyConfiguration(); CreateDefaultReceivingConfiguration(); CreateDefaultWarehousingConfiguration(); + CreateDefaultItemLedgerEntryOpenToInspectConfiguration(); end; local procedure CreateDefaultTrackingSpecificationToInspectConfiguration() @@ -1296,6 +1299,75 @@ codeunit 20402 "Qlty. Auto Configure" ''); end; + local procedure CreateDefaultItemLedgerEntryOpenToInspectConfiguration() + var + QltyInspectSourceConfig: Record "Qlty. Inspect. Source Config."; + TempItemLedgerEntry: Record "Item Ledger Entry" temporary; + TempQltyInspectionHeader: Record "Qlty. Inspection Header" temporary; + begin + EnsureSourceConfigWithFilterExists( + OpenLedgerToInspectTok, + OpenLedgerToInspectDescriptionTxt, + Database::"Item Ledger Entry", + Database::"Qlty. Inspection Header", + QltyInspectSourceConfig, + 'WHERE(Open=CONST(true))'); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Document No."), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Document No."), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Item No."), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Item No."), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Remaining Quantity"), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Quantity (Base)"), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Variant Code"), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Variant Code"), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Lot No."), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Lot No."), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Serial No."), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Serial No."), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Package No."), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Source Package No."), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo(Description), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo(Description), + ''); + EnsureSourceConfigLineExists( + QltyInspectSourceConfig, + TempItemLedgerEntry.FieldNo("Location Code"), + Database::"Qlty. Inspection Header", + TempQltyInspectionHeader.FieldNo("Location Code"), + ''); + end; + local procedure CreateDefaultProdOrderRoutingLineToItemJournalLineConfiguration() var QltyInspectSourceConfig: Record "Qlty. Inspect. Source Config."; diff --git a/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al b/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al index b63439ced1..ddf520f657 100644 --- a/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al +++ b/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al @@ -4,6 +4,7 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.QualityManagement.Document; +using Microsoft.Inventory.Ledger; using Microsoft.Inventory.Tracking; using Microsoft.QualityManagement.AccessControl; using Microsoft.QualityManagement.Configuration.GenerationRule; @@ -195,7 +196,8 @@ report 20400 "Qlty. Create Inspection" Error(NotAValidQltyInspectionTemplateErr, QltInspectionTemplateToCreate); if (NullCheckRecordId = Target) or (Target.TableNo = 0) then - Error(PleaseChooseARecordFirstErr); + if QltyInspectSourceConfig."From Table No." <> Database::"Item Ledger Entry" then + Error(PleaseChooseARecordFirstErr); end; end; } @@ -296,7 +298,8 @@ report 20400 "Qlty. Create Inspection" Dummy4Variant: Variant; begin if ((NullCheckRecordId = Target) or (Target.TableNo = 0)) then - Error(PleaseChooseARecordFirstErr); + if QltyInspectSourceConfig."From Table No." <> Database::"Item Ledger Entry" then + Error(PleaseChooseARecordFirstErr); TargetRecordRef := Target.GetRecord(); From f0d3032774152ca5b49c91895b0ee25eac4a516c Mon Sep 17 00:00:00 2001 From: aldobriansky Date: Mon, 23 Feb 2026 14:02:40 +0100 Subject: [PATCH 2/3] Restore error on not chosen record in Qtly. Create Inspection report --- .../app/src/Document/QltyCreateInspection.Report.al | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al b/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al index ddf520f657..b63439ced1 100644 --- a/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al +++ b/src/Apps/W1/Quality Management/app/src/Document/QltyCreateInspection.Report.al @@ -4,7 +4,6 @@ // ------------------------------------------------------------------------------------------------ namespace Microsoft.QualityManagement.Document; -using Microsoft.Inventory.Ledger; using Microsoft.Inventory.Tracking; using Microsoft.QualityManagement.AccessControl; using Microsoft.QualityManagement.Configuration.GenerationRule; @@ -196,8 +195,7 @@ report 20400 "Qlty. Create Inspection" Error(NotAValidQltyInspectionTemplateErr, QltInspectionTemplateToCreate); if (NullCheckRecordId = Target) or (Target.TableNo = 0) then - if QltyInspectSourceConfig."From Table No." <> Database::"Item Ledger Entry" then - Error(PleaseChooseARecordFirstErr); + Error(PleaseChooseARecordFirstErr); end; end; } @@ -298,8 +296,7 @@ report 20400 "Qlty. Create Inspection" Dummy4Variant: Variant; begin if ((NullCheckRecordId = Target) or (Target.TableNo = 0)) then - if QltyInspectSourceConfig."From Table No." <> Database::"Item Ledger Entry" then - Error(PleaseChooseARecordFirstErr); + Error(PleaseChooseARecordFirstErr); TargetRecordRef := Target.GetRecord(); From 9c73e9aea1579d94d37de02fc751ef507858e4ec Mon Sep 17 00:00:00 2001 From: aldobriansky Date: Mon, 23 Feb 2026 14:51:36 +0100 Subject: [PATCH 3/3] Do not fill in Schedule Group if a job queue is not created --- .../JobQueue/QltyJobQueueManagement.Codeunit.al | 8 +++++--- .../JobQueue/QltyScheduleInspection.Report.al | 2 +- .../GenerationRule/QltyInspectionGenRule.Table.al | 5 ++++- .../GenerationRule/QltyInspectionGenRules.Page.al | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyJobQueueManagement.Codeunit.al b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyJobQueueManagement.Codeunit.al index 145374413a..94729f242c 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyJobQueueManagement.Codeunit.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyJobQueueManagement.Codeunit.al @@ -50,20 +50,22 @@ codeunit 20455 "Qlty. Job Queue Management" /// Common usage: Called when setting up inspection generation rules to ensure scheduled execution infrastructure exists. /// /// The schedule group code to check and potentially create a job queue entry for - internal procedure PromptCreateJobQueueEntryIfMissing(ScheduleGroup: Code[20]) + internal procedure PromptCreateJobQueueEntryIfMissing(ScheduleGroup: Code[20]) JobQueueEntryCreated: Boolean begin if IsJobQueueCreated(ScheduleGroup) then - exit; + exit(true); if GuiAllowed() then if not Confirm(StrSubstNo(ThereIsNoJobQueueForThisScheduleGroupYetDoYouWantToCreateQst, ScheduleGroup)) then - exit; + exit(false); CreateJobQueueEntry(ScheduleGroup); if GuiAllowed() then if Confirm(StrSubstNo(JobQueueEntryMadeDoYouWantToSeeQst, ScheduleGroup)) then RunPageLookupJobQueueEntriesForScheduleGroup(ScheduleGroup); + + exit(true); end; /// diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al index 459bc53920..5c7151a0f8 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/JobQueue/QltyScheduleInspection.Report.al @@ -12,7 +12,7 @@ report 20412 "Qlty. Schedule Inspection" { Caption = 'Quality Management - Schedule Inspection'; AdditionalSearchTerms = 'Periodic inspections'; - ToolTip = 'This report is intended to be scheduled in the job queue to allow the ability to schedule inspections.'; + ToolTip = 'Run this report to bulk create inspections based on generation rules for the selected template, or schedule it in the job queue for periodic inspection creation.'; ProcessingOnly = true; ApplicationArea = QualityManagement; UsageCategory = Tasks; diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRule.Table.al b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRule.Table.al index 3d920abd90..cabcb388c2 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRule.Table.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRule.Table.al @@ -65,7 +65,10 @@ table 20404 "Qlty. Inspection Gen. Rule" if Rec."Schedule Group" <> '' then begin QltyJobQueueManagement.CheckIfGenerationRuleCanBeScheduled(Rec); Rec.Modify(); - QltyJobQueueManagement.PromptCreateJobQueueEntryIfMissing(Rec."Schedule Group"); + if not QltyJobQueueManagement.PromptCreateJobQueueEntryIfMissing(Rec."Schedule Group") then begin + Rec."Schedule Group" := xRec."Schedule Group"; + Rec.Modify(); + end; end else QltyJobQueueManagement.DeleteJobQueueIfNothingElseIsUsingThisGroup(Rec, xRec."Schedule Group"); end; diff --git a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRules.Page.al b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRules.Page.al index 38b1385164..5e22a09c48 100644 --- a/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRules.Page.al +++ b/src/Apps/W1/Quality Management/app/src/Configuration/GenerationRule/QltyInspectionGenRules.Page.al @@ -160,7 +160,10 @@ page 20405 "Qlty. Inspection Gen. Rules" if Rec."Schedule Group" = '' then begin Rec."Schedule Group" := DefaultScheduleGroupLbl; Rec.Modify(false); - QltyJobQueueManagement.PromptCreateJobQueueEntryIfMissing(Rec."Schedule Group"); + if not QltyJobQueueManagement.PromptCreateJobQueueEntryIfMissing(Rec."Schedule Group") then begin + Rec."Schedule Group" := ''; + Rec.Modify(false); + end end else QltyJobQueueManagement.RunPageLookupJobQueueEntriesForScheduleGroup(Rec."Schedule Group") end;