Page 20402 Qlty. Inspection Template

Quality Management, Microsoft.QualityManagement.Configuration.Template

src/Apps/W1/Quality Management/app/src/Configuration/Template/QltyInspectionTemplate.Page.al235 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.QualityManagement.Configuration.Template;using Microsoft.Foundation.Attachment;using Microsoft.QualityManagement.Configuration.GenerationRule;using Microsoft.QualityManagement.Document;using Microsoft.QualityManagement.Telemetry;/// <summary>/// A Quality Inspection Template is an inspection plan containing a set of questions and data points that you want to collect./// </summary>page 20402 "Qlty. Inspection Template"{    UsageCategory = None;    Caption = 'Quality Inspection Template';    DataCaptionExpression = GetDataCaptionExpression();    PageType = Card;    RefreshOnActivate = true;    SourceTable = "Qlty. Inspection Template Hdr.";    AboutTitle = 'About Quality Inspection Template details';    AboutText = 'A Quality Inspection Template is an inspection plan containing a tests to perform, rules defining how the template impacts processes like purchase or production.';    PromotedActionCategories = 'New,Process,Report';    ApplicationArea = QualityManagement;    layout    {        area(Content)        {            group(General)            {                Caption = 'General';                field("Code"; Rec.Code)                {                    ToolTip = 'Specifies the code to identify the Quality Inspection Template.';                    trigger OnValidate()                    begin                        if xRec.Code = '' then                            CurrPage.Update(true)                        else                            CurrPage.Update(false);                    end;                }                field(Description; Rec.Description)                {                    trigger OnValidate()                    begin                        CurrPage.Update(true);                    end;                }                field("Sample Source"; Rec."Sample Source")                {                    ShowCaption = true;                    AboutTitle = 'Sample Source';                    AboutText = 'Sample Source determines how the Sample Size initially gets set. Values are rounded up to the nearest whole number.';                    trigger OnValidate()                    begin                        UpdateControls();                    end;                }                group(SampleFixedAmountVisibilityWrapper)                {                    ShowCaption = false;                    Caption = '';                    Visible = ShowSampleSizeFixedQuantity;                    field("Sample Fixed Amount"; Rec."Sample Fixed Amount")                    {                        ShowCaption = true;                    }                }                group(SamplePercentVisibilityWrapper)                {                    ShowCaption = false;                    Caption = '';                    Visible = ShowSampleSizePercentage;                    field("Sample Percentage"; Rec."Sample Percentage")                    {                        ShowCaption = true;                    }                }            }            part(LinesPart; "Qlty. Inspection Template Subf")            {                Caption = 'Lines';                SubPageLink = "Template Code" = field(Code);                SubPageView = sorting("Template Code", "Line No.");            }        }        area(FactBoxes)        {            part("Attached Documents"; "Doc. Attachment List Factbox")            {                Caption = 'Template Attachments';                SubPageLink = "Table ID" = const(Database::"Qlty. Inspection Template Hdr."),                              "No." = field("Code");            }            part("Attached Documents List"; "Doc. Attachment List Factbox")            {                Visible = false;                Caption = 'Specification Attachments';                Provider = LinesPart;                SubPageLink = "Table ID" = const(Database::"Qlty. Inspection Template Line"),                              "No." = field("Template Code"),                              "Line No." = field("Line No.");            }            systempart(RecordLinks; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(RecordNotes; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(Processing)        {            action(CreateInspection)            {                AccessByPermission = tabledata "Qlty. Inspection Header" = I;                Caption = 'Create Inspection';                ToolTip = 'Create a new quality inspection from this template.';                Image = BulletList;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                PromotedOnly = true;                trigger OnAction()                var                    QltyCreateInspection: Report "Qlty. Create Inspection";                begin                    QltyCreateInspection.initializeReportParameters(Rec.Code);                    QltyCreateInspection.RunModal();                end;            }            action(CopyTemplate)            {                Image = Copy;                Caption = 'Copy Template';                ToolTip = 'Copy an existing quality inspection template.';                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                trigger OnAction()                var                    ExistingQltyInspectionTemplateHdr: Record "Qlty. Inspection Template Hdr.";                begin                    ExistingQltyInspectionTemplateHdr := Rec;                    ExistingQltyInspectionTemplateHdr.SetRecFilter();                    Report.Run(Report::"Qlty. Inspection Copy Template", true, true, ExistingQltyInspectionTemplateHdr);                end;            }        }        area(Navigation)        {            action(ViewRules)            {                Caption = 'Inspection Generation Rules';                ToolTip = 'View existing quality inspection generation rules related to this template.';                AboutTitle = 'Inspection Generation Rules';                AboutText = 'View inspection generation rules for this template. Quality inspection generation rules specify when quality inspections are automatically generated and which template is used, such as during receiving, production, or warehouse activities. You link a template to a source table and define filter criteria that determine when an inspection is created. When the criteria are met, the system generates a quality inspection based on the linked template. If multiple rules match, the system uses the first rule according to the sort order.';                Image = CopyFromTask;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                RunObject = Page "Qlty. Inspection Gen. Rules";                RunPageLink = "Template Code" = field(Code);                RunPageMode = Edit;                PromotedOnly = true;            }            action(ExistingInspection)            {                Caption = 'Existing Inspections';                ToolTip = 'Review existing quality inspections created using this template.';                Image = CheckList;                Promoted = true;                PromotedCategory = Process;                PromotedIsBig = true;                PromotedOnly = true;                RunObject = Page "Qlty. Inspection List";                RunPageLink = "Template Code" = field(Code);                RunPageMode = View;            }        }    }    var        ShowSampleSizeFixedQuantity: Boolean;        ShowSampleSizePercentage: Boolean;    /// <summary>    /// Builds the template caption from its code and description.    /// </summary>    /// <returns>The template page caption.</returns>    local procedure GetDataCaptionExpression(): Text    begin        exit(Rec.Code + ' - ' + Rec.Description);    end;    trigger OnAfterGetRecord()    begin        UpdateControls();    end;    trigger OnInsertRecord(BelowxRec: Boolean): Boolean    var        QltyMgmtFeatureTelemetry: Codeunit "Qlty. Mgmt. Feature Telemetry";    begin        QltyMgmtFeatureTelemetry.LogFeatureUptakeSetup(ObjectType::Page, Page::"Qlty. Inspection Template");    end;    /// <summary>    /// Updates sample-size control visibility from the configured sample source.    /// </summary>    local procedure UpdateControls()    begin        ShowSampleSizeFixedQuantity := Rec."Sample Source" = Rec."Sample Source"::"Fixed Quantity";        ShowSampleSizePercentage := Rec."Sample Source" = Rec."Sample Source"::"Percent of Quantity";    end;}