Tip #20 - Save Report Usage

This is a hot subject for a lot of companies using Navision. When was a report last executed, by whom and how many times.

The classic solution for this is to add code to every report to store this information in a table.

But it can be solved more generic...

The solution is in Codeunit 1. Here is a trigger FindPrinter that is executed prior to each report being printed. So what about implementing the solution here.

In order for this to work, we have to implement a trick, because when this code is executed, Navision is not yet in transaction state.

The trick is to save the report usage in a Temporary table first inside a SingleInstance codeunit.

What? Stick out tongue

Ok, let me explain this.

SingleInstance codeunits were introduced years ago. The benefit of this type of codeunits is that all variables are stored in client memory during the lifetime of the session. This includes temporary tables.

To activate this propery, just go in the codeunit's property window.

So what else do we need...

First of all the table to store data in. Off course you can make this as high tech as you want, but for this example we will store the Repord ID, the User ID, the number of runs and the last execution date.

The second thing we need is a management codeunit, the SingleInstance one.

This codeunit has two functions. One to populate/maintain the temporary table, and one to store the data in an actual table.

Remember to make the variable Temporary

Last change is to manage these functions from codeunit 1.

This is done in the FindPrinter and LogInEnd functions.

Remember that in both functions the RepUsageMgt codeunit is a LOCAL variable.


Oh, and yes, this works in the Role Tailored Client as well.

Comment List