Financials 1.20 question

Fred_Deutsch
Member Posts: 51
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.
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
-
And do you have the error when you run the report from the menu or another object?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
here is a solution:
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 Sub0 -
And in the script, you can let it write in a way so it is easily opened with Excel and have some statistics on it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:And do you have the error when you run the report from the menu or another object?
No, and thats what I find so curious.0 -
Morten Solberg wrote:here is a solution:
make a vbscript who write a log:
use the FileSystemObject
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.0 -
Fred Deutsch wrote:Morten Solberg wrote:here is a solution:
make a vbscript who write a log:
use the FileSystemObject
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.CREATE(LautScriptControl); LautScriptControl.Language := 'VBScript'; LautScriptControl.ExecuteStatement(LtxtScript);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:Fred Deutsch wrote:Morten Solberg wrote:here is a solution:
make a vbscript who write a log:
use the FileSystemObject
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.CREATE(LautScriptControl); LautScriptControl.Language := 'VBScript'; LautScriptControl.ExecuteStatement(LtxtScript);
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"0 -
Fred Deutsch wrote: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:Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Can you explain a "Technical Upgrade" ? - I was under the impression that any upgrades require complete recoding of all modifications (of which we have many) - also, when MS bought Navision, we opted NOT to continue the support and resource availibility options but instead bought lots of user sessions, forms, tables, reports, etc and upped our license to the highest level below developer. I was also told that this meant that to get any upgrades, we would have to pay all old fees to get current.0
-
Then find out until what version you were you on support. My guess 3.6 or 3.7. Then get that executables and install them. Open the backup database with the new client. It will ask you to upgrade, select yes, and you just did a technical upgrade. You have to make sure that you don't have the same name on the objects if you do, you need to rename them. Make sure it works with your license. Also Automation is a granuale. I don't know if you would have it on your license.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions