Tip #20 – Save Report Usage

This Blog Article was brought forward from my old blog

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.

Enjoy…

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

1 Comment

  1. Kevin Berg says:

    Is the LogInEnd() the local function in codeunit 40?

    Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.