12 March 2020

How to get MainAccount using ledger dimension recId in ax 2012

In the below code have to pass ledgerDimension recId to get the main account Id.

Table.MainAccountId             =   MainAccount::findByLedgerDimension(ledgerDimension).MainAccountId;

01 March 2020

How to extend standard report (Purchase order report ) in D365 F&O using print management / Report extension in D365

Dynamics Ax 365 SSRS: How to call new Report/Design for existing Print management report

To get the report format in the setup Print management setup:
Need to create extension for the PrintMgmtReportFormatPopulator->addDocuments()
Need to add the new report to get the report in the configuration

Step1. Duplicate the PurchPurchaseOrder standard Report as PurchPurchaseOrderADD
Step2. Go to PrintMgmtDocType class and copy the eventHandler delegate method called getDefaultReportFormatDelegate
Step3. Create new class "PrintMgmtDelegatesHandler_Test" and paste the eventHandler.

below is reference code. To execute the report different designs per each legal entity.

Once we done this - Need to go to AP-Setup-Forms->Form setup -> Print Management button then in that form have to select the that related Purchase order report in the dropdown.



class PrintMgmtDelegatesHandler_Test
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="_docType"></param>
    /// <param name="_result"></param>
    [SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void PrintMgmtDocType_getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        PrintMgmtReportFormatName formatName = PrintMgmtDelegatesHandler_Test::getDefaultReportFormat(_docType);
        if (formatName)
        {
            _result.result(formatName);
        }
    }

    private static PrintMgmtReportFormatName getDefaultReportFormat(PrintMgmtDocumentType _docType)
    {

        switch (_docType)
        {
            case PrintMgmtDocumentType::PurchaseOrderRequisition:
                {
                    if(curExt() == "USMF")
                    {
                        return ssrsReportStr(PurchPurchaseOrderADD, Report);
                    }
                    if(curExt() == "RUMF")
                    {
                        return ssrsReportStr(PurchPurchaseOrderADD, ReportRU);
                    }

                }
            case PrintMgmtDocumentType::PurchaseOrderConfirmationRequest:
                {
                    if(curExt() == "USMF")
                    {
                        return ssrsReportStr(PurchPurchaseOrderADD, Report);
                    }
                    if(curExt() == "RUMF")
                    {
                        return ssrsReportStr(PurchPurchaseOrderADD, ReportRU);
                    }
                }
        }
        return '';
    }

}

Need to execute the below job to populate new report design in the Print management setup Table(PrintMgmtReportFormat) can open see new report is inserted in this table or not after executing below populate method.

class PrintPopulateReportFormat
{
    public static void main(Args _args)
    {
        PrintMgmtReportFormatSubscriber::populate();
        
    }
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...