web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

(2) ShareShare
ReportReport
Posted on by 167
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)
  • Dan P Profile Picture
    167 on at
    Electronic Reporting: how to differentiate between the printed invoice and other invoices
    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!
  • Dan P Profile Picture
    167 on at
    Electronic Reporting: how to differentiate between the printed invoice and other invoices
    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
    167 on at
    Electronic Reporting: how to differentiate between the printed invoice and other invoices
    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.
  • Verified answer
    CA Neeraj Kumar Profile Picture
    3,742 on at
    Electronic Reporting: how to differentiate between the printed invoice and other invoices
    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
  • Adis Profile Picture
    5,645 Super User 2025 Season 2 on at
    Electronic Reporting: how to differentiate between the printed invoice and other invoices
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,340

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 835 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 640 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=fwCf+oetmrepceehn+nicned++2B0e2t5w" - Nested quantifier +.