Skip to main content

Use temporary table as form datasource in D365FO

In this article, we will learn how we can use the temporary table as a form datasource in D365. In our scenario, we will populate the temporary table at runtime and bind it with the form datasource. firstly, we will pass an argument on the clicked event and write the form datasource  init  method to populate the data in it.  In our scenario we will work on the CustTable form, we will populate the customer group in the temporary table which we create on the selected customer while clicking the button. Step 1:  Create a new table of type TempDB and add two new fields i.e., CustGroupId and CustGroup. Step 2:  We will create a new form with the pattern (List Type), then add our previously created temporary table as a datasource, and then drag both the fields CustGroupId and CustGroup on the form grid part. After the form creation, we will also create the display menu item of type  form  and use our form on it. Step 3:  We will create an extension of t...

Add New Report Format to Print Management in D365

In my previous article, I explained how to add a custom field, make some design changes, and create a chain of command of the PSAProjInvoiceDP class in the PSAProjInvoice report. In this article, we will look at how we can call our custom report that we have created in the previous article using Print Management.

What is print management?

Print management in D365 FO X++ is a powerful tool for managing and customizing your report designs. It provides a flexible way to control how your reports are printed and distributed.

Adding our report design to print management

By default, we have a PSAProjInvoice.Report report format for the Project Invoice Proposal and Invoice Journal reports. In our case, we have to add our custom design using the Print management report format. 

Project management and accounting -> Setup -> Forms -> Form setup

Print Management -> Project invoice without billing rules ->

To add a custom design firstly we have to find the document type beyond that design, I have written a query below in SQL Server:

select * from PrintMgmtReportFormat
	where name = 'PSAProjInvoice.Report'

There are two different ways to call our custom design using Print Management Setup:
  • Event Handler method
  • Chain of command.

Event Handler Method

Step 1:

Copy the event handler of the getDefaultReportFormatDelegate method of the PrintMgmtDocType class and subscribe to its event handler.


Step 2:

Create a new class and paste it. After it add logic in the method to call our custom report.
internal final class MDPrintMgmtDocTypeHandler
{
    [SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void PrintMgmtDocType_getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        switch (_docType)
        {
            case PrintMgmtDocumentType::SIProjInvoice:
                _result.result(ssrsReportStr(MDPSAProjInvoice, Report));
                break;
        }
    }

}

Chain of Command

Step 1:

We need to create COC of the addDocuments method of the PrintMgmtReportFormatPopulator class.

[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]
public final class MDPrintMgmtReportFormatPopulator_Extension
{
    protected void addDocuments()
    {
        #ISOCountryRegionCodes
        #PrintMgmtSetup

        next addDocuments();

        Add new customized document
        this.addOther(PrintMgmtDocumentType::SIProjInvoice, ssrsReportStr(MDPSAProjInvoice, Report), ssrsReportStr(MDPSAProjInvoice, Report), #NoCountryRegionId);
    }
}

Result:

Build and Sync the solution and then go to 

Project management and accounting -> Setup -> Forms -> Forms setup

Print management -> Project invoice without billing rules:

Comments

Popular posts from this blog

Use temporary table as form datasource in D365FO

In this article, we will learn how we can use the temporary table as a form datasource in D365. In our scenario, we will populate the temporary table at runtime and bind it with the form datasource. firstly, we will pass an argument on the clicked event and write the form datasource  init  method to populate the data in it.  In our scenario we will work on the CustTable form, we will populate the customer group in the temporary table which we create on the selected customer while clicking the button. Step 1:  Create a new table of type TempDB and add two new fields i.e., CustGroupId and CustGroup. Step 2:  We will create a new form with the pattern (List Type), then add our previously created temporary table as a datasource, and then drag both the fields CustGroupId and CustGroup on the form grid part. After the form creation, we will also create the display menu item of type  form  and use our form on it. Step 3:  We will create an extension of t...

Display method and their alternative in D365

In this article, we will learn how to add a field to the VendTable form in Dynamics 365 using the display method and the alternative of using view. The field would be populated on two different locations whose navigations are as below: Navigation 1: Account payable -> Vendors -> All vendors Navigation 2:  Account payable -> Vendors -> All vendors -> Payment tab Add field using Display Method Display Method:  Any method which has a display keyword as a modifier is a display method. You can use the display method on formdatasource, tables, and forms. Display methods are used where we want to show additional information on the forms or reports such as field computation, getting value from different tables without creating active relationships on the datasource level, and so on.  Step 1: We will create an extension of table VendTable and after creating an extension we will create a COC of the table which contains our custom display method. To improve the perfor...

Inserting Data in Table using Query::insert_recordset

When dealing with performance, there is a query system control named Query::Insert_Recordset.  This allows multiple records to be inserted into a table in the same way the Insert_Recordset command works. This will also eliminate the  need to loop over hundreds of records, as well as roundtrips between the SQL server and the AOS server.  Here is a quick demo of how it works:  Query query = new Query(queryStr(MDTrvExpenseDetailsQuery)); QueryRun queryRun; QueryBuildDataSource qbdsTrvExpTrans, qbdsTrvExpTable, qbdsProjTable, qbdsHcmWorker, qbdsDirPerson; Map fieldMapping; HcmPositionWorkerAssignment hcmPositionWorkerAssignment; HcmPosition hcmPosition; MDTrvExpenseDetailsContract contract = this.parmDataContract() as MDTrvExpenseDetailsContract; paymentStatus...