Use of Methods in D365FO Electronic Reporting Explained. Table vs Table Records & Class vs Object.

In this video, we are going to see in detail the different Electronic reporting Data Source types that have methods, and how to use them. We will see with an example how to call and use a method with parameters, and also in the post you will find a brief summary of the video with all the content in a very short read, for the blog post format lovers out there. I promise both formats are worth the time!

How to use a method in Electronic Reporting:

To consume a method in ER, unlike we do in the X++ code, you have to call first the method including the ‘()’ in the name, and later you will add the parameters if any. (if there are no parameters, just calling the method name will do the job). An example of a method being called using parameters is:

StaticObjects.CustGroup.'findByCompany()'("USRT","Retail")

Where we are consuming the static method findByCompany of the table CustGroup, that receives the DataAreaId as the first parameter and the CustGroupId as the second one.

Different ER Data types that use methods. Table vs Table Record/Object vs Class.

In the example above we have seen the consumption of a static method of a table. That was achieved using a variable of type “Table”. The 4 data types that can use methods are:

  • Table type: Gives access to static methods of tables. Commonly used to access find methods in tables and so on.
  • Table Records type: Gives access to the Table data, and also the instance methods. (methods that need a record to be executed, and they are run at record level.)
  • Class Type: Gives access to static methods of Classes. You can then access logic in static methods like in the common, or even create you own XXXERUtils class where to put logic that you can reuse across all the different ERs.
  • Object Type: It is an instance of a class, normally filled from code in ER object runtime. A common example is a Data Contract filled from code and used, or a Data Provider.

Many times I get questions around this topic, and understanding the different scenarios where to use each of them, as well as knowing how to run and access all the methods we need is crucial to take a step ahead in your way to be an ER expert.

Thanks for your attention!


4 thoughts on “Use of Methods in D365FO Electronic Reporting Explained. Table vs Table Records & Class vs Object.

  1. When you use table records and tick the cross company option it appears that the table methods only return values in the legal entity that you’re running the ER report, not all the other legal entities. Is there any work around? For example to bind PurchTable.lastInvoiceDate() for use with ALL legal entities.

    Like

    1. I never had to do that, but it is very possible that the code behind the scenes is doing cross-company queries but not changing to the record company to run the logic. The only solution I see would be to write a new method that calls the standard one, but running the ChangeCompany if the record (this) is in a different company. It will require code though, I don´t see right now a different approach.

      Like

  2. HI I need help to design vendor payment advice report where payment journal line voucher number to be populated on Payment advice as payment reference. could you please help me with this?

    Like

    1. I usually answer questions that are related to the content I post. You are asking here for a private consulting, and I would need to study the case and maybe set up a paid collaboration. Thanks in advance and good luck with your journey with ER!

      Like

Leave a comment