Skip to main content

Notifications

Custom SSRS report by leveraging the use of standard out of box functionality using Print Management in D365 FO

Recently I came across a requirement to create a custom design for Purchase order return. But here is a catch.
 
The standard and the custom report should run from single menuitem. That means if the Purchase type is returned order then the custom design in other case the standard report should execute.

Then I did some research and analysis, but my main question is how to return a report based on a condition? Because first thing with a single menu item I need to show two reports. I cannot directly extend the standard menuitem because it should show the standard design too. So, without duplicating how to do it?

Then I found the print management in D365FO where we can add new designs and can run them based on a condition.

What did I do using print management?

Here the Print management of D365 FO has some standard capability to run different types of reports based on condition. So, we can just configure whatever report we require and run it.

So why to wait?
 
Let's navigate to the detail.

For this, we will go to Procurement & Sourcing module > Setup > Forms > Form setup.
Now on clicking Print Management, we will get a page as below. So based on the document type, a new design can be applied to a standard report.
 
Right click the Purchase order and click New. Under the report format you can select your custom report if you directly want to replace the standard completely.
Now to run a report based on a condition then we have a setting feature. But here I don’t explain each and every field here. Will just go to the main topic. Just right click the Original and click New.
Under the Condition node we will specify a condition so it will work only for return order report.
On clicking select under condition, the following screen appears.
Add a new record and clicks joins to add the Purchase order so that we can get the Purchase Type field under fields column in the above table. After adding the join you should be able to see as below when you click the dropdown.
Finally, the query looks like this.
On clicking Ok, you should see your condition updated.

Now the Report format is the place where you should select your custom report.
 
Oops!! I do not find that.
 

Wait. The first thing is to add this report in one table using a class so that we will get it here under configuration.

So, following the general process, prior the print management setup or code creation, we will first create a SSRS report. 

Main thing is we need to make sure to have all parameters of the standard Purchase order report in the custom contract as we are running it from same place and make the report parameters to null if we are not using. Either way would be to duplicate the report add design and write code to populate the values and set it in print management.
 
But here we will just create new design completely using all artifacts.
 

For this,
   we must extend one standard class called, PrintMgmtReportFormatPopulator. Here, extend the addDocuments() method using COC. This step adds the custom report into the PrintMgmtReportFormat table so that we can be able to see our custom report in the Print Management setup.

Below is the code.
 
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]
public final class PBPrintMgmtReportFormatPopulator_Extension
{
    #ISOCountryRegionCodes
    #PrintMgmtSetup

    protected void addDocuments()
    {
        this.addPurchReturnDocuments();

        next addDocuments();
    }

    /// <summary>
    /// Adds custom purchase order reports into standard PrintMgmtReportFormat table
    /// </summary>
    public void addPurchReturnDocuments()
    {
        this.addOther(PrintMgmtDocumentType::PurchaseOrderRequisition,
           ssrsReportStr(PBPurchaseReturnOrder, Report),
           ssrsReportStr(PBPurchaseReturnOrder, Report), #NoCountryRegionId);
    }

}
Using standard out of box functionality of F & O, we can achieve this functionality.
 

Comments

*This post is locked for comments