COUNT FIND error

zappyzappy 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
Tomas Zadrapa

Answers

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    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-03
  • krikikriki Member, Moderator Posts: 9,112
    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!


  • zappyzappy Member Posts: 15
    edited 2018-09-06
    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 :smile:
    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 Zadrapa
Sign In or Register to comment.