COUNT FIND error

zappy
Member Posts: 15
I have little bit problem with NAV ;-) I have very simple testing Code and I run it in Codeunit by Job Queue.
MyRec.Reset;
MyRec.SETRANGE( ... );
EventLogManagement.AddInfo('COUNT ' + FORMAT (OPImportHeader.COUNT));
IF OPImportHeader.FINDFIRST THEN
EventLogManagement.AddInfo('FIRST');
IF OPImportHeader.FINDLAS THEN
EventLogManagement.AddInfo('LAST');
IF OPImportHeader.FINDSET THEN
EventLogManagement.AddInfo('SET');
EventLogManagement.AddInfo is my function which write to special log.
And the problem is: I have these records in my log:
COUNT 23
LAST
but not FIRST, not SET. Next time there is COUNT 0, FIRST, LAST, SET. Any idea why?
If I run it from client it's always OK.
Version NAV 2017
MyRec.Reset;
MyRec.SETRANGE( ... );
EventLogManagement.AddInfo('COUNT ' + FORMAT (OPImportHeader.COUNT));
IF OPImportHeader.FINDFIRST THEN
EventLogManagement.AddInfo('FIRST');
IF OPImportHeader.FINDLAS THEN
EventLogManagement.AddInfo('LAST');
IF OPImportHeader.FINDSET THEN
EventLogManagement.AddInfo('SET');
EventLogManagement.AddInfo is my function which write to special log.
And the problem is: I have these records in my log:
COUNT 23
LAST
but not FIRST, not SET. Next time there is COUNT 0, FIRST, LAST, SET. Any idea why?
If I run it from client it's always OK.
Version NAV 2017
Tomas Zadrapa
0
Answers
-
Why do you set your filters on MyRec var, but then use OPImportHeader variable for logging?
I'd be rather looking into EventLogManagement.AddInfo function. Comment your code like below and see what happens.//EventLogManagement.AddInfo('COUNT ' + FORMAT (OPImportHeader.COUNT)); EventLogManagement.AddInfo('COUNT 23'); //IF OPImportHeader.FINDFIRST THEN EventLogManagement.AddInfo('FIRST'); //IF OPImportHeader.FINDLAS THEN EventLogManagement.AddInfo('LAST'); //IF OPImportHeader.FINDSET THEN EventLogManagement.AddInfo('SET');
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Instead of using EventLog, try MESSAGE to see what happens.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
To Slawek_Guzek:
Sorry, there is everywhere MyRec .. I just rewrite the original code to basic code and this part I forget rewrite. So the code is:
MyRec.Reset;
MyRec.SETRANGE( ... );
EventLogManagement.AddInfo('COUNT ' + FORMAT (MyRec.COUNT));
IF OPImportHeader.FINDFIRST THEN
EventLogManagement.AddInfo('FIRST');
IF OPImportHeader.FINDLAS THEN
EventLogManagement.AddInfo('LAST');
IF OPImportHeader.FINDSET THEN
EventLogManagement.AddInfo('SET');
And if I comment the code, I have got right log records. So 4 records and COUNT 0, FIRST, LAST and SET.
To kriki
Yes I can use Message and after that read EventLog in system. And the result is exactly the same. Count and LAST works, First and SET not. Or better I have got random result :-(
Funny Code is this:
IF MyRecFINDFIRST then
MESSAGE ('1');
IF MyRecFINDFIRST then
MESSAGE ('2');
and I have only 2 in EventLog ;-)
Any IDEA?Tomas Zadrapa0
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