Tuesday, August 9, 2022

How to add a new dataset to SalesInvoice report in D365FO.

 Steps for adding new data source in salesInvoice report.

  • created New temp / regular table. Set the CreateTransactionId property to Yes in table and sync it.
  • For DP class we have 2 ways.
  • Way 1 : Using COC.
[ExtensionOf(classStr(SalesInvoiceDP))]
final class MySalesInvoiceDP_Extension
{   public MySalesInvoiceTmp     mySalesInvoiceTmp;

    [SRSReportDataSetAttribute(tableStr(MySalesInvoiceTmp))]
    public MySalesInvoiceTmp getMySalesInvoiceTmp()
    {
        select mySalesInvoiceTmp;
        return mySalesInvoiceTmp;
    }
}  

  • Way 2 : Using Extends
[SRSReportParameterAttribute(classStr(SalesInvoiceContract))]
class mySalesInvoiceDP extends SalesInvoiceDP
{
      public MySalesInvoiceTmp     mySalesInvoiceTmp;
    [SRSReportDataSetAttribute(tableStr(MySalesInvoiceTmp))]
    public MySalesInvoiceTmp getMySalesInvoiceTmp()
    {
        select mySalesInvoiceTmp;
        return mySalesInvoiceTmp;
    }
}

Methods:

protected void populateSalesInvoiceTmp(CustInvoiceJour _custInvoiceJour,
        CustInvoiceTrans _custInvoiceTrans,
        TaxSpec _taxSpec,
        CustPaymSchedLine _custPaymSchedLine,
        CustTrans _prepaymentCustTrans,
        TaxTrans _prepaymentTaxTrans)
    {
	// For extends
        super(_custInvoiceJour, _custInvoiceTrans, _taxSpec,
		 _custPaymSchedLine, _prepaymentCustTrans, _prepaymentTaxTrans);
	
	//COC you use
	next populateSalesInvoiceTmp(_custInvoiceJour, _custInvoiceTrans, _taxSpec,
		 _custPaymSchedLine, _prepaymentCustTrans, _prepaymentTaxTrans);

	//Write the code here If your added new fields in salesInvoiceTmp table
	//If some data exist in salesInvoiceTmp table this method will not trigger
	//So you need to delete existing records   
    }

   protected void populateSalesInvoiceHeaderFooterTmp(CustInvoiceJour _custInvoiceJour, 
                                                        CompanyInfo _companyInfo)
   {
      // For extends
      super(_custInvoiceJour, _companyInfo);

      //COC you use
	next populateSalesInvoiceTmp(_custInvoiceJour, _custInvoiceTrans, _taxSpec,
		 _custPaymSchedLine, _prepaymentCustTrans, _prepaymentTaxTrans);
    
     //Write the code here If your added new fields insalesInvoiceTmp
   }

 

  •  Duplicate standard SalesInvoice report and create custom design.
  • Right click on dataSets and add a new dataset. set the datasource type as Report data provider, dynamic filters = yes. select SaleSInvoiceDP in options and click next. 
  • Select your data source.
  • Add that data source in design and your fields. 

Print Management :
  •     PrintmgmtDocType
final static class MyPrintMgmtDocType_EventHandler
{     
    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {   switch (_docType)
        {
            case PrintMgmtDocumentType::SalesOrderInvoice:
                _result.result(ssrsReportStr(MySalesInvoice, Report));
                break;
        }  
    } 
}  
If you want add new element in print management write below code.
[ExtensionOf(classstr(PrintMgmtReportFormatPopulator))]
final class MyPrintMgmtReportFormat_Extension
{
    protected void addDocuments()
    {
        this.addStandard(PrintMgmtDocumentType::SalesOrderInvoice);
        next addDocuments();
    } 
}    
Run the below line in job.
PrintMgmtReportFormatPopulator::construct().populate();    

Keep daxing!!

No comments:

Post a Comment