Tuesday, March 21, 2023

New Print management related logic in D365FO X++

/// <summary>

/// Event handler class to define customize reprot list based on new print management type

/// </summary>

class SAN_PrintMgmtDocTypeCustAccStatementEventHandlers

{

    [SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]

    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)

    {

        switch(_docType)

        {

            case PrintMgmtDocumentType::SAN_CustAccountStatement:

                _result.result(ssrsReportStr(SAN_CustAccountStatementsExt, Report));

                break;

        }

    }


    /// <summary>

    /// Delegate handler for the getQueryRangeFieldsDelegate method of the <c>PrintMgmtDocType</c> class.

    /// </summary>

    /// <param name = "_docType"><c>PrintMgmtDocumentType</c> enumeration value.</param>

    /// <param name = "_result">The <c>EventHandlerResult</c> object.</param>

    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getQueryRangeFieldsDelegate))]

    public static void getQueryRangeFieldsDelegateHandler(PrintMgmtDocumentType _docType, EventHandlerResult _result)

    {

        List fields = new List(Types::Integer);

        if(_docType == PrintMgmtDocumentType::SAN_CustAccountStatement)

        {

            fields.addEnd(fieldNum(CustTable, AccountNum));

            fields.addEnd(fieldNum(CustTable, CustGroup));

            fields.addEnd(fieldNum(CustTable, AccountStatement));

            _result.result(fields);

        }

    }


    /// <summary>

    /// Delegate handler for the getPartyTypeDelegate method of the <c>PrintMgmtDocType</c> class.

    /// </summary>

    /// <param name = "_docType"><c>PrintMgmtDocumentType</c> enumeration value.</param>

    /// <param name = "_jour"><c>Common</c> object containing journal record.</param>

    /// <param name = "_result">The <c>EventHandlerResult</c> object.</param>

    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getPartyTypeDelegate))]

    public static void getPartyTypeDelegateHandler(PrintMgmtDocumentType _docType, Common _jour, EventHandlerResult _result)

    {

        if (_docType == PrintMgmtDocumentType::SAN_CustAccountStatement)

        {

            _result.result(PrintMgmtPrintDestinationPartyType::Customer);

        }

    }


    /// <summary>

    /// Delegate handler for the getQueryTableIdDelegate method of the <c>PrintMgmtDocType</c> class.

    /// </summary>

    /// <param name = "_docType"><c>PrintMgmtDocumentType</c> enumeration value.</param>

    /// <param name = "_result">The <c>EventHandlerResult</c> object.</param>

    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getQueryTableIdDelegate))]

    public static void getQueryTableIdDelegateHandler(PrintMgmtDocumentType _docType, EventHandlerResult _result)

    {

        if (_docType == PrintMgmtDocumentType::SAN_CustAccountStatement)

        {

            _result.result(tableNum(CustTable));

        }

    }


}




/// <summary>

/// The <c>FormLetterReport</c> class is used to retrieve the print management settings for the

/// <c>PrintMgmtDocumentType</c> enumeration value.

/// </summary>

[PrintMgmtDocumentTypeFactoryAttribute(PrintMgmtDocumentType::SAN_CustAccountStatement)]

class SAN_SalesFormLetterReport_CustAccountStatement extends SalesFormLetterReport

{

    /// <summary>

    /// Gets the default printer settings for the specified <c>PrintSetupOriginalCopy</c> enumeration value.

    /// </summary>

    /// <param name="_printCopyOriginal">

    /// The <c>PrintSetupOriginalCopy</c> enumeration value that specifies whether the Original or Copy

    /// destinations should be retrieved.

    /// </param>

    /// <returns>

    /// The default printer settings for the specified <c>PrintSetupOriginalCopy</c> enumeration value.

    /// </returns>

    protected container getDefaultPrintJobSettings(PrintSetupOriginalCopy _printCopyOriginal)

    {

        SRSPrintDestinationSettings printSettings = PrintMgmtSetupSettings::initDestination();


        printSettings.printMediumType(SRSPrintMediumType::Screen);

        return printSettings.pack();

    }


    /// <summary>

    /// Gets the <c>PrintMgmtDocumentType</c> enumeration value that specifies the document that this

    /// <c>FormLetterReport</c> class controls.

    /// </summary>

    /// <returns>

    /// The <c>PrintMgmtDocumentType</c> enumeration value that specifies the document that this

    /// <c>FormLetterReport</c> class controls.

    /// </returns>

    /// <remarks>

    /// This value is used to retrieve the appropriate Print Management settings for the report.

    /// </remarks>

    public PrintMgmtDocumentType getPrintMgmtDocumentType()

    {

        return PrintMgmtDocumentType::SAN_CustAccountStatement;

    }


    /// <summary>

    /// Gets the <c>PrintMgmtHierarchyType</c> enumeration value that specifies the hierarchy that this

    /// <c>FormLetterReport</c> class uses.

    /// </summary>

    /// <returns>

    /// The <c>PrintMgmtHierarchyType</c> enumeration value that specifies the hierarchy that this

    /// <c>FormLetterReport</c> class uses.

    /// </returns>

    /// <remarks>

    /// This value is used to retrieve the appropriate Print Management settings for the report.

    /// </remarks>

    protected PrintMgmtHierarchyType getPrintMgmtHierarchyType()

    {

        return PrintMgmtHierarchyType::Sales;

    }


    /// <summary>

    /// Gets the <c>PrintMgmtNodeType</c> enumeration value that specifies the node that this

    /// <c>FormLetterReport</c> class uses.

    /// </summary>

    /// <returns>

    /// The <c>PrintMgmtNodeType</c> enumeration value that specifies the node that this

    /// <c>FormLetterReport</c> class uses.

    /// </returns>

    /// <remarks>

    /// This value is used to retrieve the appropriate Print Management settings for the report.

    /// </remarks>

    protected PrintMgmtNodeType getPrintMgmtNodeType()

    {

        return PrintMgmtNodeType::CustTable;

    }


}




/// <summary>

/// Extension class for PrintMgmtDelegatesHandler to handle custom print management type

/// </summary>

[ExtensionOf(classStr(PrintMgmtDelegatesHandler))]

final class PrintMgmtDelegatesHandlerCls_SAN_Extension

{

    /// <summary>

    /// Determines the party type for a journal records and the current document type.

    /// </summary>

    /// <param name="_jour">

    /// A journal record.

    /// </param>

    /// <returns>

    /// A member of <c>PrintMgmtPrintDestinationPartyType</c>.

    /// </returns>

    /// <exception cref="Exception::Error">

    /// An invalid combination of journal record and document type was found.

    /// </exception>

    protected static PrintMgmtPrintDestinationPartyType getPartyType(PrintMgmtDocumentType _docType, Common _jour)

    {

        PrintMgmtPrintDestinationPartyType polPartyType;


        polPartyType = next getPartyType(_docType, _jour);


        switch (_docType)

        {

            case PrintMgmtDocumentType::SAN_CustAccountStatement:

                return PrintMgmtPrintDestinationPartyType::Customer;

        }


        return polPartyType;

    }


}


/// <summary>

/// Extension class for PrintMgmtNode_CustTable to incoporate new print management node as Polaris customer account statement

/// </summary>

[ExtensionOf(classStr(PrintMgmtNode_CustTable))]

final class PrintMgmtNode_CustTableCls_SAN_Extension

{

    public List getDocumentTypes()

    {

        List ret;

        ret = new List(Types::Enum);

        ret = next getDocumentTypes();

        ret.addEnd(PrintMgmtDocumentType::SAN_CustAccountStatement);


        return ret;

    }


}



/// <summary>

/// This class is used to extend the print management

/// </summary>

[ExtensionOf(classStr(PrintMgmtNode_Sales))]

final class PrintMgmtNode_SalesCls_SAN_Extension

{

    /// <summary>

    /// This class is used to extend the print management

    /// </summary>

    /// <returns>docTypes</returns>

    public List getDocumentTypes()

    {

        List docTypes; 

        docTypes = new List(Types::Enum); 

        docTypes = next getDocumentTypes();

        docTypes.addEnd(PrintMgmtDocumentType::SAN_CustAccountStatement);

        return docTypes;

    }


}



/// <summary>

/// New class to populate the data in PrintMgmtReportFormat table

/// </summary>

[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]

final class PrintMgmtReportFormatPopulatorCls_SAN_Extension

{

    #PrintMgmtSetup


    /// <summary>

    /// extension of method to populate the data in PrintMgmtReportFormat table

    /// </summary>

    protected void addDocuments()

    {

        next addDocuments();

        this.addOther(PrintMgmtDocumentType::SAN_CustAccountStatement, ssrsReportStr(SAN_CustAccountStatementsExt, Report), ssrsReportStr(SAN_CustAccountStatementsExt, Report), #NoCountryRegionId);

    }


}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...