How to pick up a message from the system ?

subhastersubhaster Member Posts: 64
edited 2007-07-12 in Navision Attain
Hi everyone !
I came across a scenario, where I have to pick up the error message that comes because of validating any field. As I am using NAS , and NAS does not support GUI, I cannot pick up the display message just like that. Say , on validating a wrong data to Product Group Code of the Item table, the error comes up some thing like this :-
'Product Group Code 'T' does not exist' (where T= data that was fed into the Item category code field). Can anyone tell me , how can I pick this error message ?
Subhasish Chakraborty,
Systems Analyst,
MBS Dynamics.

Comments

  • DenSterDenSter Member Posts: 8,307
    Those error message will be in the event log. Go to the Windows Event Viewer to see the messages.

    There's no way to catch errors, NAV does not have an error object. You will have to program your functionality to check for errors before validating fields, so you can program around them. In 5.0 there's a LASTERRORMESSAGE method or something like that, which you can use for this.

    What I've done in the past is to program all field validation in a codeunit, and call the codeunit in an IF statement. Inside the codeunit I would keep track of which field I was validating, so if that errored out I could fish the message out of the codeunit. This would still not be the actual error message, but still you'd know what was going on and you can log it into an error log table.
  • subhastersubhaster Member Posts: 64
    Thanks a lot Den.... :D
    the method that you asked to use is : 'GETLASTERRORTEXT' which returns a string type variable. I tapped it and moulded it as an XML . It worked !!!
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
  • subhastersubhaster Member Posts: 64
    However, there is one exeception to this rule. Say the moment an error is raised, the prgram execution halts there. So if write something, in the 'On Validate' ecevnt, those chunks of code will not be executed.
    I have written at the on validate event of Department :-
    IF Department.GET(Dept) THEN
       "Dept Name":=Department."Dept Name";
    
    CREATE(XmlDom);
    
    XMLDOMManagement.SetNormalCase;
    XMLProccesingInst := XmlDom.createProcessingInstruction('xml','version=''1.0'' encoding=''utf-8''');
    XMLCurrNode := XmlDom.appendChild(XMLProccesingInst);
    
    CLEAR(XMLCurrNode);
    XMLCurrNode := XmlDom.createElement('ResponseXml');
    XmlDom.appendChild(XMLCurrNode);
    
    XMLCurrNode2 := XmlDom.createElement('Error');
    XMLCurrNode2.text:=GETLASTERRORTEXT;
    XMLCurrNode.appendChild(XMLCurrNode2);
    
    XmlDom.save('D:\Error.xml');
    CLEAR(XmlDom);
    

    But the code stops at that point of time only, if some wrong department value is nenetered .It wont look at the next lines of code. So the Error message contains a null value !
    Please suggest me , how to come around this .
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.
Sign In or Register to comment.