Wednesday, 19 July 2023

D365 FO - How to trigger electronic reporting using X++ to export the file

 Scenario: On clicking the button, electronic reporting should be triggered to export the data based on the input parameter (Journal number) and attach the file against the journal header


ERFormatMappingId      formatMappingId;        

ERFormatMappingTable      mappingTable; 

ERIFormatMappingRun formatMappingRun;


const str erParmJournalNum = 'parameters.JournalNum’;

FileName   downloadfileName = paymentProcessingSetup.fileName + today();

// Add the input parameter – journal num so that it export the lines only for that journal

ERModelDefinitionInputParametersAction modelDefinitionInputParametersAction = new ERModelDefinitionInputParametersAction();

modelDefinitionInputParametersAction. addParameter(erParmJournalNum, _journalNum)

// export the data in the file based on the input parameters by setting electronic reporting ID and file name 

formatMappingRun = ERObjectsFactory::createFormatMappingRunByFormatMappingId(paymentProcessingJournalSetup.ERID,  paymentProcessingSetup.fileName).withParameter(modelDefinitionInputParametersAction);

 // attach the file to attachments in journal header

Var  fileDestination = ERObjectsFactory::createFileDestinationAttachmentWithDocuType(directDebitHeader, ‘File’);

formatMappingRun.withFileDestination(fileDestination);

formatMappingRun.parmShowPromptDialog(false);

formatMappingRun.run();

}

Sunday, 18 March 2018

How to refresh the form from the class after an update in AX 2012

  

    Scenario: Here, Let's take Purchase confirmation report as example. If SRSPrintMediumType is Email, I have to track the information ( to whom the email was sent, at what time) in purchase order confirmation form under new tab named tracking tab. Log records will be inserted inside the class. Once the Email has been sent, form has to be refreshed.

 Under PurchPurchaseOrderController class, under main method - after the report operation has been completed

     if (formHasMethod(_args.caller(), identifierStr(refreshPurchComDS)))
    {
       _args.caller().refreshPurchComDS();
    }
     Method refreshPurchComDS():

    public void refreshPurchComDS()
{
    DWPurchComEvents_ds.reread();
    DWPurchComEvents_ds.refresh();
    DWPurchComEvents_ds.research();
}



}
}



s