When was a report last used ?

I am planning to create a table to show when a report was last used. I would put some update code in the OnPreDataItem of every report to either insert or modify the table with the user id, date, time and the object number. Before I do this I feel I must ask the question: “Is this the only way to find out when a report was last run ?” Any Comments appreciated?

Today is Your lucky day :slight_smile: You only need to add code in codeunit 310 to accomplish this. //Lars

I’m afraid modifying cu310 is not enough. What about all the reports run directly from a form-menu? You also need to modify all codeunits which issue reports. That is: CU 82, 92, 228, 229, 232, 234, 242, 252, 272, 282, 310, 372 This list is complete for Fin 2.0. I had to cope with this problem in october 1999. You might therefore want to check if new codeunits have been implemented in the meantime which start reports. ------- With best regards from Switzerland Marcus Fabian

Sorry. I was wrong. But it’s still Your lucky day. Instead of codeunit 310 You can put Your code in codeunit 1 in the function FindPrinter. That function is called no matter haow You run a report. //Lars

Thanks for the help so far… However, when attempting to add or modify the table from the Codeunit 1 FindPrinter function I get the message; “You cannot make any changes to the database from this trigger”. Looks like I have to do it the long way.

Hi Robin I just tried it my self and there was no problem with it. I put some code just before the function exits. There I inserted a row in a table and it works fine no matter from where i print the report. Try again. //Lars

Hi All, I’ve tried it with NF 2.0, 2.01B and 2.60A. And it works really fine. There must be another reason, that you cannot write to the database. Perhaps you decribe exactly what you do and what code you’ve implemented?! Greetings, Frank

The Code I have used is shown below: <------------- code starts ------------> FindPrinter(ReportID : Integer) : Text[80] CLEAR(PrinterSelection); IF NOT PrinterSelection.GET(USERID,ReportID) THEN IF NOT PrinterSelection.GET(’’,ReportID) THEN IF NOT PrinterSelection.GET(USERID,0) THEN IF PrinterSelection.GET(’’,0) THEN; //mod rc - Tell the last used system who is doing this IF ObjectLastUsed.GET(ObjectLastUsed.“Object Type”::Report, ReportID) THEN ObjectLastUsed.MODIFY(TRUE) ELSE BEGIN ObjectLastUsed.INIT; ObjectLastUsed.“Object Type” := ObjectLastUsed.“Object Type”::Report; ObjectLastUsed.“Object ID” := ReportID; ObjectLastUsed.INSERT(TRUE); END; //end mod EXIT(PrinterSelection.“Printer Name”); <----------- code ends ------------------> The table structure is as follows: Field Name Data Type Length Object Type Option Object ID Integer Object Name Text 30 User ID Code 10 Date Date Time Time The OnModify and OnInsert Code in the table just updates the user, date and time fields. “User ID” := USERID; Date := TODAY; Time := Time; Robin

Hi Robin, I’ve tested it with NF 2.01B. I have made the same table and the same code at. And it works! What reports do you call for your test? Greetings, Frank

I think, that problem is not in the code, but in place from where you call the code. That is exactly what the error message says: “You cannot make any changes to the database from this trigger”. I have experienced this sort of errors when I tried to modify record from some of Form triggers. If possible then try to put code in another trigger. Michal

i noticed that people who had success with this are not from the UK.(and i presume not using the UK version) i got the same error in the US version. Could it be a country version difference? regards

Hi Steve, it cannot depend on the the country version, because Ralph Mayer uses the same version as i do: the german one. My code work, his not. I think the reason must be somewhere in the trigger from where the function is called! Did you debug, Robin, Ralph? Greetings, Frank

I tried to enter the code in Navision GB 2.01A and GB 2.60A When I run for example the report “Customer Register” from Sales/Reports then everything is OK and record in new table is created. But if I attempt to run report by pressing button “Print” on Posted Invoice then I get the old big error screen about Run Modal / Commit. (It says, that Run Modal can not be used within a write transaction - which is what has happened there) So I guess that both groups are right. Sometimes it causes error message, sometimes it works fine. Michal

Thanks for all your help so far. The code works fine if I run the report from a reports option off the menu screens. It fails with the error message, if I call a report directly or run a report from the Object Designer. You do not get the error message the first time you run it, nothing prints either, but you do get the message if you run it again. Confused Robin

Hello. I was wondering if anyone that was originally getting the “You cannot make any changes to the database from this trigger” message finally got it working? I’m having the same problem here with Navision 3.7. Thanks!

Hi everybody This is a solution without touch any CodeUNIT if you work with navision 3.70 Use the Change log functionality In fact , it is enough to create a new table with the field for example → Report no. And in your report just add a record or modify it in this table Configure the trace log functionality standard navision … And so all is ok Navision give you all the information you’re waiting for Bye

quote:


Originally posted by marvax
Hi everybody This is a solution without touch any CodeUNIT if you work with navision 3.70 Use the Change log functionality In fact , it is enough to create a new table with the field for example → Report no. And in your report just add a record or modify it in this table Configure the trace log functionality standard navision … And so all is ok Navision give you all the information you’re waiting for Bye


But you have to change all the reports, that you want to trace. Changing codeunit better option Bostjan

quote:


Originally posted by Lars Westman
Sorry. I was wrong. But it’s still Your lucky day. Instead of codeunit 310 You can put Your code in codeunit 1 in the function FindPrinter. That function is called no matter haow You run a report. //Lars


But, if you set the Probpert UseSystemPrinter = TRUE this Trigger will not be executed. Regards Bastian