I am trying to track report usage, I have noticed that running any report triggers CodeUnit 1 - Application Management.FindPrinter, passing the report ID. So, I made a new Table "Report Usage" with two fields "ReportID" and "Frequency" - both integers, then added this code to CodeUnit 1 - Application Management.FindPrinter:
IF ReportUsage.GET(ReportID) THEN BEGIN
ReportUsage.Frequency := ReportUsage.Frequency + 1;
ReportUsage.MODIFY;
END
ELSE BEGIN
ReportUsage.INIT;
ReportUsage."Report ID" := ReportID;
ReportUsage.Frequency := 1;
ReportUsage.INSERT;
END;
If I run any report from the std menus, this seems to work fine, however running reports directly from the Object Designer gives the following Error:
"You cannot make changes to the Database from this trigger"
This happens regardless of whether the report has been run before or not.
Oops forgot to say I also specifically added permisson to modify/insert the ReportUsage Table to both the codeunit 1 as well as to all users.
Any ideas why and how to fix this would be greatly appreciated.
0
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
make a vbscript who write a log:
use the FileSystemObject
CodeUnit 1:
In the FindPrinter Trigger
insert code before the EXIT function:
str := STRSUBSTNO('wscript c:\myReportLog.vbs %1',ReportID);
SHELL(str);
EXIT(PrinterSelection."Printer Name");
the vbscript:
Option Explicit
On Error Resume Next
Dim ReportID
Call fctGetParameters
Call WriteLog(ReportID)
Sub WriteLog(parReportID)
Dim FSO, FileTxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const FileName = "C:\ReportLog.txt"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set FileTxt = FSO.OpenTextFile(FileName, ForAppending, True)
FileTxt.WriteLine("then text comes here: including reportID: " & parReportID)
FileTxt.Close
Set FSO = Nothing
End Sub
Sub fctGetParameters
Dim objArgs
Set objArgs = WScript.Arguments
ReportID = objArgs(0)
End Sub
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No, and thats what I find so curious.
I thought of that but I see a few problems, we have nearly 50 users, so each user would have to have a copy of the script on their workstation, then I'd have 50 seperate logs to assemble. Also about half of our users are remoted in via Metaframe / NT 4 TS, which makes strange drive letter assignments and may have problems running VB or VB Script. I may not have a choice though. I'm mainly curious as to why running a report directly from the Designer errors, while running a report from the Reports Menu or a form does not error. Time to enable the Debugger again I guess.
variable : LautScriptControl Automation 'Microsoft Script Control 1.0'.ScriptControl
and "LtxtScript" contains your script.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I'm sorry but I do not understand this post - is the code above Navision Code ? Remember this is Financials US1.20, there is no Variable Type "Automation"
Yes it is Navision code, but for later versions.
You might do a technical upgrade to 4.0SP1 so you can use automation. :whistle:
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n