web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Electronic Reporting: how to differentiate between the printed invoice and other invoices

(3) ShareShare
ReportReport
Posted on by 280
Hello Dynamics Community and forum members,
 
I'm trying to figure out how Electronic Reporting identifies the current object that is being printed out, and how that filtering is applied when accessing the database. I'm printing out free text invoices, and from what I can tell when a reference is made to CustInvoiceJour, this includes filtering on the current invoice being printed.
 
However, I added a calculated field to the model mapping, which is referencing CustInvoiceJour. The purpose is to identify if the current invoice has values in certain fields. This reference to CustInvoiceJour does not seem to include filtering on the current invoice being printed.
 
Here is the formula my calculated field is using in the model mapping's data source section, under calculated fields:
 
FIRSTORNULL( WHERE( CustInvoiceJour.'$CustInvoiceTrans_OrderByLineSeqNum', CustInvoiceJour.'$CustInvoiceTrans_OrderByLineSeqNum'.Prefix_CompanyId <> "" ) )
 
I would assume that since CustInvoiceJour is being referenced, the report would have added, or already done, the filtering of the current invoice number. But that does not happen.
 
I was wondering if the filtering on current object being printed is controlled by where in the model mapping the call to the calculated field is located. So I moved it from under the root definition InvoiceCustomer to under InvoiceCustomer>InvoiceBase. But this made no difference.
 
I probably need to refine the description above but do let me know what is unclear. I'm trying to avoid sharing screenshots as I suspect this could be sensitive to share.
Categories:
I have the same question (0)
  • Adis Profile Picture
    6,686 Super User 2026 Season 1 on at
    Hi,
     
    Do you want to prevent users from printing it or do something if the condition is met?
     

    Kind regards, Adis

     

    If this helped, please mark it as "Verified" for others facing the same issue

    Keep in mind that it is possible to mark more than one answer as verified

  • Verified answer
    CA Neeraj Kumar Profile Picture
    5,135 Super User 2026 Season 1 on at
    Hi, 
     
    The filter given by MS is based on "Ask for Query" selected in CustInvoiceJour table and while running the report, the query is passed to the DP classes to execute for selected invoices.
     
     
    Please let us know what is not working in your case.. If you want to get more clarity, debugger is the best way to do it.
     
    Regards,
    Neeraj Kumar
  • Dan P Profile Picture
    280 on at
    Hi Adis,
     
    "Do you want to prevent users from printing it or do something if the condition is met?"
     
    I want to filter out information based on this invoice and include it in the model mapping so I can print it out in the XML-file.
  • Dan P Profile Picture
    280 on at
    Hi Neeraj,
     
    "The filter given by MS is based on "Ask for Query" selected in CustInvoiceJour table and while running the report, the query is passed to the DP classes to execute for selected invoices."
     
    I see, that's good to be aware of, thank you! However, in the calculated field, I am referencing these tables records (I'll add below), the same as are being referenced in other places of the report, yet when I reference them from the calculated field, it appears as if the filtering is not being done in relation to the current invoice.
     
    FIRSTORNULL( WHERE( CustInvoiceJour.'$CustInvoiceTrans_OrderByLineSeqNum', CustInvoiceJour.'$CustInvoiceTrans_OrderByLineSeqNum'.Prefix_CompanyId <> "" ) )
     
    I'll see if the debugger helps, thank you for the suggestion!
     
    Edit: Actually, I think the debugging illustrates that the records are actually filtered on the current invoice, and my problem is something else.
  • Dan P Profile Picture
    280 on at
    Ok so the debugger showed me that the filtering was actually being performed correctly, as it seems. So then I took another look at the format mapping to the model and the model mapping, and I noticed there was a reference to a record field before checking if there was a record, and this gives an error message when there's no record.
     
    Thanks to Neeraj, helping me identify the issue, explaining how the report activates the report query on a record list (I'll have to experiment with this to understand in detail) and also thanks to Adis for helping!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 608

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 591 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans