We have a Web Site that is calling NAV via Web Services (NAV 2009 SPI) for certain things such as Inventory Qty, Customer Comments etc...
I have created a web service log table in NAV that records the Function, Time, Parameters passed in and the return response. So when the website calls Web Services the first thing the function does in NAV is records this Web Service record.
My problem is that I am unble to record errors in the Web Service Log since upon error NAV rolls back. It does a great job of passing the error back to the calling web service but I am wondering if there is a way to capture the Error and record it to the log table that I created. An example of where this works is the Navision Timer 1.0 .dll that works nicely with a Single instance NAS Codeunit.
0
Comments
in 2009 commits were ignored and you can write your code in sp1
if not codeunit.run and then
get last error
write it to log
commit
error(getlasterror);
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Great suggestion and my current structure (Web Service Codeunit calling another codeunit's OnRun) can easily accommodate your suggestion. I'll try it out and get back to you.
jwilder@stonewallkitchen.com
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
ara3n your suggestion works but I was wrong about it flowing good with what I already have. To call Codeunit.Run requires quite a bit of restructuring with what I already have.
All great suggestions, any other thoughts?
jwilder@stonewallkitchen.com
You can create a new Codeunit.
create a new function in it called set parameters.
Inside this codeunit call your existing codeuni on the run trigger.
clear(newCU);
newCU.setParameers(Customer, Comments, ItemNo., etc, etc);
If not NewCu.run then begin
end; else begin
end;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The SetParameter functions certainly solves the problem I will keep it in mind but it just doesn't seem worth it at this point. It makes the code less clear and adds another codeunit to the process.
Thanks for your help!
jwilder@stonewallkitchen.com
In your webservice C# code write call this function in your code.
Try
{
Webservice.callsomefunction;
} catch
{
Webservice.insertlog(EventError);
}
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n