How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;   ...

Customize SSRS report using extension in D365FO


Customize SSRS report using extension in D365FO:



We have done the following steps:
·         Create extension of FreeTextInvoiceTmp table and add the field i.e. TotalAmounInWords

·         Create a class named FreeTextInvoiceController_Events to implement the event handler methods


·         Copy the post handler event method of processReport() of FreeTextInvoiceDP class and paste in the class created in previous step.

·         NOTE: You can also use the OnInserting event of table instead of processReport() of DP class.

·         Write the following logic to insert the data into the
·        
TotalAmounInWords field we have created:

class FreeTextInvoiceController_Events
{
    [PostHandlerFor(classStr(FreeTextInvoiceDP), methodStr(FreeTextInvoiceDP, processReport))]
    public static void FreeTextInvoiceDP_Post_processReport(XppPrePostArgs args)
    {
        FreeTextInvoiceDP dpInstance = args.getThis() as FreeTextInvoiceDP;
        FreeTextInvoiceHeaderFooterTmp freeTextInvoiceHeaderFooterTmp = dpInstance.getFreeTextInvoiceHeaderFooterTmp();
        FreeTextInvoiceTmp freeTextInvoiceTmp = dpInstance.getFreeTextInvoiceTmp();
        ttsbegin;
        while select forUpdate freeTextInvoiceTmp
        {
            freeTextInvoiceTmp.TotalAmounInWords = numeralsToTxt(freeTextInvoiceTmp.InvoiceAmount);
            freeTextInvoiceTmp.update();
        }
        ttscommit;
    }


Find out the FreeTextInvoice report in the AOT,

·         Right-click the report and click Duplicate in project.

·         Customize the design and add TotalAmountInWords field as per your requirements


·         Create another class named FreeTextInvoiceControllerExt which extends the FreeTextInvoiceController class. Override the main() method. Give the new report and it’s design name in it.

·         Add the following logic in FreeTextInvoiceControllerExt class:


class FreeTextInvoiceControllerExt extends FreeTextInvoiceController
{
    public static FreeTextInvoiceControllerExt construct()
    {
        return new FreeTextInvoiceControllerExt();
    }

    public static void main(Args _args)
    {
        SrsReportRunController formLetterController = FreeTextInvoiceControllerExt::construct();
        FreeTextInvoiceControllerExt controller = formLetterController;
        controller.parmReportName(ssrsReportStr(FreeTextInvoiceCopy, Report));
        controller.parmArgs(_args);
        controller.startOperation();
    }
}

·         Create another class named PrintMgtDocTypeHandlersExt

·         Add a method in it which subscribes to the event delegate of PrintMgmtDocType class to re-route the report from the default to this customized report


·         Add the following logic in PrintMgtDocTypeHandlersExt class:


class PrintMgtDocTypeHandlersExt
{
    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        switch (_docType)
        {
            case PrintMgmtDocumentType::SalesFreeTextInvoice:
                _result.result(ssrsReportStr(FreeTextInvoiceCopy, Report));
                break;
        }
    }
}


·         Create extension of the following menu items which executes report:

·         FreeTextInvoiceCopy

·         FreeTextInvoiceOriginal


·         Change the controller class name in the Object property of the extended menu items to the FreeTextInvoiceControllerExt class created above
·         Save, build and synchronize and deploy the project/reports.


Comments

Popular posts from this blog

D365 FO: REFRESH CALLER FORM DATA SOURCE FROM A CLASS X++

Passing Args from one Form to another Form in dynamics AX

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX