Options

Navision Timer

ara3nara3n Member Posts: 9,255
Navision Timer 1.0
Hello I read in the following topic
http://www.mibuso.org/forum/viewtopic.p ... highlight=

about being able to catch the navision erros using The timer automation with the event TimerError.
Here is my code. TempCU suppose to basically just errors out every time.
IF ISCLEAR(MyTimer) THEN
  CREATE(MyTimer);
MyTimer.Interval := 1000;
MyTimer.Enabled := TRUE;

MyTimer::Timer(Milliseconds : Integer)
if TempCU.RUN then;
  
MyTimer::TimerError(ErrorString : Text[1024])
MESSAGE(ErrorString);


What I expect from this is that TimerError Event would tigger and message would show me the ErrorString. Unfortunately it doesn't work.
What am I doing wrong? Has anybody tried this?
Thanks in advance.
Ahmed Rashed Amini
Independent Consultant/Developer


blog: https://dynamicsuser.net/nav/b/ara3n

Comments

  • Options
    jreynoldsjreynolds Member Posts: 175
    Just do TempCU.RUN. Get rid of the "IF ... THEN" as this syntax causes Navision to return a Boolean resault rather than throwing the error.
  • Options
    ara3nara3n Member Posts: 9,255
    My whole point is to run with if TempCU.RUN then. And if there are any errors, still continue and be able to get the error through the TimerError Event.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I would guess the error can only be logged if the error occurs in the same object as where the OnTimer-event is used.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    ara3nara3n Member Posts: 9,255
    If the error is within the codeunit, then you can't use if codeunit.run. and the error would terminate the code you are running.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    DenSterDenSter Member Posts: 8,304
    Well that would happen anyway. The point of using that timer error event is to see if you can catch the error description, to maybe log the error messages in a special table. Using IF Codeunit.RUN prevents the calling transaction from aborting, and finish a transaction assuming that an error was raised.

    Two different things for two different purposes.
  • Options
    Peter_WijntjesPeter_Wijntjes Member Posts: 28
    As far as I know this only works when running from NAS.
    when run interactively the ErrorDialog will popup prior to triggering the TimerErrorEvent.

    ](*,)
    Peter Wijntjes
    MBS NAV Consultant
Sign In or Register to comment.