Codeunit 583 Acc. Sched. Report Caption

App
Base Application
Namespace
Microsoft.Finance.FinancialReports
Versions
17-28

Versions171819202122232425262728

Source29

Source in 29

src/Layers/W1/BaseApp/Finance/FinancialReports/AccSchedReportCaption.Codeunit.al46 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.Finance.FinancialReports;

using System;
using System.Threading;
using System.Xml;

/// <summary>
/// Provides custom report captions for account schedule reports in the report scheduling system.
/// Enhances report descriptions by retrieving account schedule names from XML request parameters.
/// </summary>
/// <remarks>
/// Integrates with Schedule a Report page to display meaningful report descriptions
/// instead of generic report names when scheduling account schedule reports.
/// </remarks>
codeunit 583 "Acc. Sched. Report Caption"
{

    trigger OnRun()
    begin
    end;

    [EventSubscriber(ObjectType::Page, Page::"Schedule a Report", 'OnGetReportDescription', '', false, false)]
    local procedure OnGetReportDescription(var ReportDescription: Text[250]; RequestPageXml: Text; ReportId: Integer; var IsHandled: Boolean)
    var
        AccScheduleName: Record "Acc. Schedule Name";
        XMLDOMManagement: Codeunit "XML DOM Management";
        XMLDocument: DotNet XmlDocument;
        XMLNode: DotNet XmlNode;
    begin
        if not IsHandled then
            if ReportId in [REPORT::"Account Schedule"] then
                if XMLDOMManagement.LoadXMLDocumentFromText(RequestPageXml, XMLDocument) then begin
                    XMLNode := XMLDocument.SelectSingleNode('//Field[@name="AccSchedName"]');
                    if AccScheduleName.Get(CopyStr(XMLNode.InnerText, 1, MaxStrLen(AccScheduleName.Name))) then begin
                        ReportDescription := AccScheduleName.Description;
                        IsHandled := true;
                    end;
                end;
    end;
}