Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Custom sales invoice report in D365

(2) ShareShare
ReportReport
Posted on by 604
Hi Experts,

I have a requirement to create a custom Sales Invoice report that needs to be printed occasionally based on specific customer requests. I don't want to modify the standard Sales Invoice report—instead, I’d like to create a separate report and add a dedicated button to print it. Ideally, I’d like to avoid using Print Management. If it's possible to leverage the existing classes (like the standard data provider and contract), I’d only need to create a custom design and expose it through the form. Could anyone share some guidance or references on how to achieve this?
Categories:
  • Nisarg  Jani Profile Picture
    296 on at
    Custom sales invoice report in D365
     
    Can you debug the code with the check for the value difference in the Parameters with your scenarios?
     
    I recommend duplicating the existing Sales Order Invoice Controller class, to other scenarios will need to be handled.
     
    Did you create a new Custom Report or Duplicated Existing Report to add your design?
     
    Make sure your Project does contain your custom Report, and it is deployed and build before checking out.
     
    Regards,
    Nisarg Jani
     
     
     
     
  • D365  beginner Profile Picture
    604 on at
    Custom sales invoice report in D365
    Hi Nisarg,
     
    Thank you for your inputs, I have already tried those parameters including default values but no luck. Is there anything else I should make sure ? 
  • Nisarg  Jani Profile Picture
    296 on at
    Custom sales invoice report in D365
     
    The Reports contains certain parameters below the design tab.
     
    For Certain parameters Like Location in Sales Invoice Report need to set allow null and Blank property to True otherwise, Report will pass you the error.
     
     
    Regards,
    Nisarg Jani
  • D365  beginner Profile Picture
    604 on at
    Custom sales invoice report in D365
    public class CustomSalesInvoiceController extends SrsReportRunController
    {
        CustInvoiceJour custInvoiceJour;
        SalesInvoiceContract salesInvoiceContract;
     
        public static CustomSalesInvoiceController construct()
        {
            return new CustomSalesInvoiceController();
        }
     
        protected void preRunModifyContract()
        {
            salesInvoiceContract = this.parmReportContract().parmRdpContract();

            salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
            salesInvoiceContract.parmIsTaxInvoice(custInvoiceJour.isRealizedVAT());
            salesInvoiceContract.parmDocumentTitle("Custom Invoice");
            salesInvoiceContract.parmLanguageId(custInvoiceJour.LanguageId);
            salesInvoiceContract.parmFormLetterRecordId(custInvoiceJour.RecId);
            salesInvoiceContract.parmLocation(TaxUnrealizedDocuPrintLocation::None); 
       
            super();
        }
     
        public static void main(Args _args)
        {
            CustInvoiceJour custInvoiceJour = _args.record();
            if (!custInvoiceJour)
            {
                throw error("No invoice record found.");
            }
            CustomSalesInvoiceController controller = CustomSalesInvoiceController::construct();
            controller.parmReportName(ssrsReportStr(CustomSalesInvoice, Report)); 
            controller.parmShowDialog(false);
            controller.parmArgs(_args);
            controller.custInvoiceJour = custInvoiceJour;
            controller.startOperation();
        }
    }

    Can anyone help me to identify what is wrong with above controller class for this requirement, I am getting below error while trying to print the report. I tried to set the default value for the parameter and it works with invoices that does not have sales orders (Imported opening balance sales invoices). 

    Value cannot be null. Parameter name: location 
  • Suggested answer
    Nisarg  Jani Profile Picture
    296 on at
    Custom sales invoice report in D365
    Hi,
     
    To create a new button that opens Custom Sales Order as following:
     
    Create a Form Extension and add new button for your custom report, 
     
    Create a menu item with Controller class that calls Custom Report (if necessary) and map the menu item to Form button.
     
    Create a Custom Report (I suggest duplicating the existing Sales Invoice Report and modify the report as required.) and refresh/ add the data source as standard DP Class.
     
    If you need to add custom Fields to Report, then you need to create extension for the TMP table and create CoC in DP Class.
     
    You will require to add a Secuity Privilege to have access to menu item (If your user role is not assigned System Admin Role).
     
    Regards,
    Nisarg Jani  
  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    13,685 Super User 2025 Season 1 on at
    Custom sales invoice report in D365
    Hi,
    As a workaround, if it's possible to define when this report should be printed (e.g. based on specific conditions or criteria), you can add a new entry in Print Management via the UI. Then, configure it to trigger this report for the defined condition, and run it manually via the Print or View action buttons.
     
  • Martin Dráb Profile Picture
    233,741 Most Valuable Professional on at
    Custom sales invoice report in D365
    Usually you can simply use parmReportName() method of the report controller to set the report design. But when print management is involved, it overrides your choice with the rules defined by print management, therefore you need to influence the print management itself. I guess that SalesInvoiceController.printSettingDetail() may be a good place.
  • D365  beginner Profile Picture
    604 on at
    Custom sales invoice report in D365
    Hi Martin,
     
    I need to do it in D365 F&O. 
  • Martin Dráb Profile Picture
    233,741 Most Valuable Professional on at
    Custom sales invoice report in D365
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum, because the question seems to be about either Dynamics AX or D365FO. Please clarify which product you mean.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 510 Most Valuable Professional

#2
Saalim Ansari Profile Picture

Saalim Ansari 315

#3
Adis Profile Picture

Adis 312 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans