Weird XMLPort error behavior

kalljakallja Member Posts: 5
Hello folks,

I've run into a situation where XMLPort-produced errors are not handled properly in Nav 5. I've tested the same functionality in Nav 2009 R2 Classic client. XMLPort related errors do not behave in the expected way there either, though behavior is different from Nav 5.

The errors themselves are correct content-vise so that is not the issue here.

The scenario:
An XMLPort import is run from a form either directly or via an intermediate Codeunit. The import being run terminates with an error. The nature of the error is not relevant as long as it is produced by the XMLPort itself. The call to the XMLPort.IMPORT(Integer, InStream) function is wrapped in an IF-statement to handle any errors.

The Problem:
XMLPort.IMPORT does indeed return false to indicate that an error was encountered. Custom code handles the error.
The next time an object (any object) is run via the object designer the error raised by the XMLPort is shown in the normal error dialog even if CLEARLASTERROR was called by the error handling code.

Here is some code demonstrating the issue by using an uninitialized InStream.
On a form, OnPush trigger of a button:
IF NOT XMLPORT.IMPORT(69999, lInStream) THEN BEGIN
  MESSAGE(GETLASTERRORTEXT)
END

The exact same code can be put into a Codeunit, that get's executed from the form with the exact same result. The key factor here is executing the XMLPort import from a form.

The question here is: how can i prevent the error dialog from being shown the next time an object is run? This obviously is the way Nav should behave.

Thank you in advance for your invaluable input.


- Kallja

Comments

  • KrasseKrasse Member Posts: 3
    Hi Kallja

    i saw your post and i got the same problem. You can try to do this:

    IF NOT XMLPORT.IMPORT(8002,LInStream) THEN BEGIN
      ERROR('');
    END;
    

    It will show your Error-Message, but you also cleared the last Error.

    Hope this helps!

    Greetings from Austria!
Sign In or Register to comment.