How to pick up a message from the system ?

subhaster
Member Posts: 64
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 ?
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.
Systems Analyst,
MBS Dynamics.
0
Comments
-
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.0 -
Thanks a lot Den....
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.0 -
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions