Options

Fault Tolerance for Errors

Saint-SageSaint-Sage Member Posts: 92
Hello all,

I am working as a developer and my company is using Nav 3.7 with a 3.1 database. We have something similar to Job Scheduler that we leave running constantly. It checks a table called Dispatch Control every 60 seconds for a job that it must perform. If it finds one, it runs a corresponding report or codeunit.

The problem is this. Occasionally a part will come in from the commerce portal that is not in Navision. If that happens, Navision throws an error and we have to restart navision, add the item, then restart the Dispatcher. The same thing happens if there is a printer that runs out of paper or gets a paper jam. The whole process stops, and navision sets quiet with an error message displayed and when everyone comes in in the morning, we have to re-run the entire process.

Job scheduler does something similar however, it spits out an error message and then marks the codeunit to re-run at a later time. I would like to do something similar as our current fault tolerance is not acceptable.

My question is this, is there any way that I can trap errors in navision, spit out a report and then remove the modal error box and continue processing, similar to the way Job Scheduler does it?

Thanks for any help or comments you can give, even if it's not a solution.

No one loves you like the one who created you...

Comments

  • Options
    Alex_ChowAlex_Chow Member Posts: 5,063
    One way you can go about it is to update your process to do error checking first.

    If an error occurs during checking, have the record be inserted into another table, then delete the record so the process won't stop.

    After that, the user just need to go to the new table with problem records and address them one by one.

    Basically, something like:
    IF NOT Item.GET(ItemNo) THEN BEGIN
      TableA.TRANSFERFIELDS(TableB);
      TableA.INSERT;
      TableB.DELETE;
    END;
    
  • Options
    Saint-SageSaint-Sage Member Posts: 92
    Thanks for the tip brokenlizard, I was working on something similar but your code is more straightforward. That will solve the problem with placing orders for which there is no item and that is one of our major hitches. I would like to still be able to set up some type of system so that the Dispatcher will still run regardless if it runs into an error. Sometimes there are errors like the printer running out of paper etc. Regardless of how often we tell the client to make sure that stuff is taken care of it winds up happening due to user error.

    The structure is this...

    Form Dispatcher has timer on 60 seconds....
    ->
    Reads Table Dispatch Control and if it finds
    a line that has a time/date stamp later than
    current then execute that report/codeunit/dataport.
    ->
    Writes to a Table Dispatch Log before and after
    codeunit/report/dataport runs.

    If it runs into an error in any of these, it breaks.
    There are roughly 20 units called by dispatcher and each unit is several hundred lines of code. I could check all the states of data called in the codeunit before calling the codeunit, but that would be an arduous task to write, and it wouldn't stop things like printer errors.

    Basically I need the ability to do a :
    Try
    Run Codeunit
    Catch
    Write to Error Log
    Reset Dispatch Control Table entry for next run date/time
    End Catch

    Run Next Codeunit...

    But I don't think there is a try/catch in navision?

    Thanks for any help anyone can give...

    No one loves you like the one who created you...
  • Options
    Alex_ChowAlex_Chow Member Posts: 5,063
    After the error log is written, why not run a report based on the error log table?

    What we did for a client was to run the error log form after the process is complete. But instead of a form, you can use a report.
  • Options
    Saint-SageSaint-Sage Member Posts: 92
    Ok, I may have found the fix in the Tips+Tricks Section of Mibuso.

    If CODEUNIT.RUN() THEN BEGIN

    END ELSE BEGIN

    END;

    Should work. My problem was not processing an error log, but getting an error log to print when any kind of error occured within a codeunit/report/dataport without the system just hanging on the error.

    I will update the post when I have it implemented and working, otherwise I will write a ranting post after two days of it not working :lol:

    Thanks again for the help BL.

    No one loves you like the one who created you...
  • Options
    SavatageSavatage Member Posts: 7,142
    Curious about the Printer out of paper part. Wouldn't it just sit in the printers Queue until the printer problem was resolved? or do you have it set up differently Cause I don't understand why no paper would stop an import.
  • Options
    ara3nara3n Member Posts: 9,256
    Make sure you put COMMIT in the correct place in your code.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Saint-SageSaint-Sage Member Posts: 92
    ara3n, thanks for the tip, I checked for what you were talking about and commiting the data before I call each sucessive codeunit can help me provide a more efficient system. Have a great day!

    No one loves you like the one who created you...
  • Options
    ara3nara3n Member Posts: 9,256
    It's recommend to commit after the Codeunit has run successfully.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    Take a look at report 297, it does basically what you are after.
    David Singleton
  • Options
    Saint-SageSaint-Sage Member Posts: 92
    Thanks for the help everyone, it looks like the solution is going to work well. I will post the specifics of the solution once it's finished. Everyone have a great day!

    No one loves you like the one who created you...
Sign In or Register to comment.