Problem usring GETLASTERRORTEXT

marcoseavermarcoseaver Member Posts: 7
I am currently using XMLport to import SO into Nav. Since the program will be called using Job Queue, I tried to avoid all the popup errors / message. I have tried the following code to call the XMLPort using a CodeUnit:
IF NOT XMLPORT.IMPORT(XMLPORT::"Import XML",g_insInStream) THEN BEGIN
    //MESSAGE(GETLASTERRORTEXT);
    ErrorLog(l_recQueue,g_txtCompanyName,g_txtSONo,GETLASTERRORTEXT);
END;

However, the GETLASTERRORTEXT method cannot get me the last error message if there occurs an error in the XMLPort.

I have also tried using one CodeUnit to call another CodeUnit. This time, it works.

Anybody can explain this and give me some help. Thx in advance.

Comments

  • kinekine Member Posts: 12,562
    I am currently using XMLport to import SO into Nav. Since the program will be called using Job Queue, I tried to avoid all the popup errors / message. I have tried the following code to call the XMLPort using a CodeUnit:
    IF NOT XMLPORT.IMPORT(XMLPORT::"Import XML",g_insInStream) THEN BEGIN
        //MESSAGE(GETLASTERRORTEXT);
        ErrorLog(l_recQueue,g_txtCompanyName,g_txtSONo,GETLASTERRORTEXT);
    END;
    

    However, the GETLASTERRORTEXT method cannot get me the last error message if there occurs an error in the XMLPort.

    I have also tried using one CodeUnit to call another CodeUnit. This time, it works.

    Anybody can explain this and give me some help. Thx in advance.

    It is because the command is only working with the codeunit "if codeunit.run then". But you can ask Microsoft if it was intended to work with XMLPort too and this is a bug, or it is by design.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • marcoseavermarcoseaver Member Posts: 7
    kine wrote:
    I am currently using XMLport to import SO into Nav. Since the program will be called using Job Queue, I tried to avoid all the popup errors / message. I have tried the following code to call the XMLPort using a CodeUnit:
    IF NOT XMLPORT.IMPORT(XMLPORT::"Import XML",g_insInStream) THEN BEGIN
        //MESSAGE(GETLASTERRORTEXT);
        ErrorLog(l_recQueue,g_txtCompanyName,g_txtSONo,GETLASTERRORTEXT);
    END;
    

    However, the GETLASTERRORTEXT method cannot get me the last error message if there occurs an error in the XMLPort.

    I have also tried using one CodeUnit to call another CodeUnit. This time, it works.

    Anybody can explain this and give me some help. Thx in advance.

    It is because the command is only working with the codeunit "if codeunit.run then". But you can ask Microsoft if it was intended to work with XMLPort too and this is a bug, or it is by design.

    Thanks for your reply.

    The GETLASTERRORTEXT command actually can capture the error message that has been popped up and not yet been cleared by CLEARLASTERROR command, no matter the error is raised by codeunit or xmlport or anything else.
  • kinekine Member Posts: 12,562
    Than the question is, if the code in the example is really fired, when there is some error inside the XMLPort or the code is not executed because the error in the XMLPort will cancel the transaction and the processing...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • marcoseavermarcoseaver Member Posts: 7
    kine wrote:
    Than the question is, if the code in the example is really fired, when there is some error inside the XMLPort or the code is not executed because the error in the XMLPort will cancel the transaction and the processing...

    Yeah, that's the problem #-o

    Than how can I get the error message without terminate the transaction and the process? ](*,)
  • kinekine Member Posts: 12,562
    without encapsulation into codeunit... I do not know about any other way around...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • marcoseavermarcoseaver Member Posts: 7
    kine wrote:
    without encapsulation into codeunit... I do not know about any other way around...

    I tried to use another codeunit to call the codeunit which calls the XMLPort, and use the same IF codeunit THEN... code. But it cannot bypass the error window.
  • kinekine Member Posts: 12,562
    Hmmm... than try to ask Microsoft, seems that error handling in XMLPort is done in some different way. Which error you have?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.