Codeunit 8353 MCP Config Missing Object in 28

App
System Application
Namespace
System.MCP

Procedures, 4

Versions171819202122232425262728latest

Source2829

Source in 28

src/System Application/App/MCP/src/Configuration/Codeunits/MCPConfigMissingObject.Codeunit.al64 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 System.MCP;

using System.Reflection;

codeunit 8353 "MCP Config Missing Object" implements "MCP Config Warning"
{
    Access = Internal;
    InherentEntitlements = X;
    InherentPermissions = X;

    var
        MCPConfigurationTool: Record "MCP Configuration Tool";
        MissingObjectWarningLbl: Label '%1 (%2) referenced by this configuration no longer exists in the system.', Comment = '%1=Object type, %2=Object Id';
        MissingObjectFixLbl: Label 'Remove this tool from the configuration.';

    procedure CheckForWarnings(ConfigId: Guid; var MCPConfigWarning: Record "MCP Config Warning"; var EntryNo: Integer)
    var
        AllObj: Record AllObj;
    begin
        MCPConfigurationTool.SetRange(ID, ConfigId);
        if MCPConfigurationTool.FindSet() then
            repeat
                case MCPConfigurationTool."Object Type" of
                    MCPConfigurationTool."Object Type"::Page:
                        AllObj.SetRange("Object Type", AllObj."Object Type"::Page);
                    MCPConfigurationTool."Object Type"::Query:
                        AllObj.SetRange("Object Type", AllObj."Object Type"::Query);
                end;
                AllObj.SetRange("Object ID", MCPConfigurationTool."Object ID");
                if AllObj.IsEmpty() then begin
                    MCPConfigWarning."Entry No." := EntryNo;
                    MCPConfigWarning."Config Id" := ConfigId;
                    MCPConfigWarning."Tool Id" := MCPConfigurationTool.SystemId;
                    MCPConfigWarning."Warning Type" := MCPConfigWarning."Warning Type"::"Missing Object";
                    MCPConfigWarning.Insert();
                    EntryNo += 1;
                end;
            until MCPConfigurationTool.Next() = 0;
    end;

    procedure WarningMessage(MCPConfigWarning: Record "MCP Config Warning"): Text
    begin
        if MCPConfigurationTool.GetBySystemId(MCPConfigWarning."Tool Id") then
            exit(StrSubstNo(MissingObjectWarningLbl, MCPConfigurationTool."Object Type", MCPConfigurationTool."Object Id"));
    end;

    procedure RecommendedAction(MCPConfigWarning: Record "MCP Config Warning"): Text
    begin
        exit(MissingObjectFixLbl);
    end;

    procedure ApplyRecommendedAction(var MCPConfigWarning: Record "MCP Config Warning")
    begin
        if MCPConfigurationTool.GetBySystemId(MCPConfigWarning."Tool Id") then
            MCPConfigurationTool.Delete();
        MCPConfigWarning.Delete();
    end;
}

Procedures, 4

NameParametersReturnsAccessObsolete
CheckForWarnings(Guid, var Record MCP Config Warning, var Integer)public-
WarningMessage(Record MCP Config Warning)Textpublic-
RecommendedAction(Record MCP Config Warning)Textpublic-
ApplyRecommendedAction(var Record MCP Config Warning)public-