Capturing unhandled errors in JavaScript Control Add-ins

  • Reading time:3 mins read

Not that I am saying it’s a good thing, but trial and error is a fairly common approach to debugging in the NAV world. We’ve all done it. Heck, even with the comprehensive testability framework built in, we all still do it more often than we’re happy to admit while sober.

But the overlord of trial and error in NAV is development of control add-ins in JavaScript. JavaScript itself is making it difficult in the first place, and then integration with NAV makes it even harder.

There is one situation in particular that’s adding a cherry on top of all of problems, and it’s the creepy “A script error has occurred” error message. It’s the equivalent of the BSoD.

Continue ReadingCapturing unhandled errors in JavaScript Control Add-ins

Getting the exception type from the GETLASTERROROBJECT

  • Reading time:4 mins read

In my last post I have introduced the GETLASTERROROBJECT function that returns you the instance of the System.Exception class, representing the actual exception that has happened.

To properly handle exceptions in an unambiguous way, you must use the exception type, not its name, so it is important to get the actual System.Type representing the exception type.

Sounds easy, but it’s not quite so.

Continue ReadingGetting the exception type from the GETLASTERROROBJECT

Better error handling in NAV 2015

  • Reading time:3 mins read

You may love C/AL as a language, but there is an area in it that you must just hate. It’s the error handling. Plainly put, and being actually quite positive about it, in NAV, error handling just sucks. If an error happens, it happens. You have only one possibility to actually capture the error, and it’s the IF CODEUNIT.RUN construct, and it’s limited because you can do it only once per transaction, and if you want to do it twice, you must COMMIT your transaction first.

But still, capturing an error is one thing; actually handling it is quite a different thing altogether.

Continue ReadingBetter error handling in NAV 2015

Web Reference vs. Service Reference, Part 2

  • Reading time:4 mins read

imageA beauty of Web services is that they don’t need to care at all about who’s consuming them. Whether there is .NET on Windows, Java on Linux or some proprietary stuff on an iPad on the other end, they do exactly the same stuff.

To make it short: if something works on one platform and fails on another platform, it’s not the fault of the Web service being called, it’s the fault of the caller platform.

As I said in the last post, there are two ways, or platforms if you wish, native to .NET Framework, which you can use to connect to any Web services. And they don’t work exactly the same.

Continue ReadingWeb Reference vs. Service Reference, Part 2

Strange errors in RoleTailored Client RDLC reports

  • Reading time:3 mins read

olddogWe old dogs really have to learn new tricks with RTC (RoleTailored Client), as I found out couple of days ago. A customer of mine asked me for a quick report. I don’t typically do reports, but I thought—“not a big deal, it’s just a report”—so I fixed it, tested it, made sure it worked, then deployed it to production.

And then I found out it was not just a report.

It just didn’t want to execute in production. Whatever I did I just got a strange error message, something I never saw before. Ever.

Continue ReadingStrange errors in RoleTailored Client RDLC reports

Some more issues with my blog

  • Reading time:1 min read

image “Perfect is the enemy of good”, a smart person said once. Another one said: “If it works, don’t mess with it.”

So, I messed with it. I was trying to make it perfect.

Over past couple of weeks, you might have experienced downtimes, or even errors such as 403 Access Forbidden or similar here on my blog. The reason is—I was trying to make it perfect, and now I see that good might have been good enough.

As a part of my blog reviving efforts, I’ve tried improving the performance. The blog was awfully slow, so I offloaded the static content to CDN and installed the W3 Total Cache plugin to help me improve my speed. Which it did. For a while.

Then it started behaving funny, and was intermittently and unpredictably throwing errors at my visitors, for which I sincerely apologize. You don’t deserve to be thrown errors at. Honestly.

So, I’ve switched the page caching off for the time being, while I try to sort it out. In the meanwhile, I ask my fellow bloggers, if you are using WordPress and W3 Total Cache, and have experienced something similar—please help.

Continue ReadingSome more issues with my blog

Error With Exposing Currencies As Web Services

  • Reading time:4 mins read

If you try exposing Page 5 Currencies as a Web service in Microsoft Dynamics NAV 2009, and then consuming this web service through a .NET application, you are almost guaranteed to encounter some unhelpful and generic XML errors that give you absolutely no clue about what exactly, where and why, went wrong.

Here’s an example of the error:

There is an error in XML document (1, 3634).

The error took me a while to debug and pinpoint the source, but in the end I managed to find a neat solution which I find worth sharing here, just in case somebody out there is scratching their had over it.

Continue ReadingError With Exposing Currencies As Web Services

Featuritis Cure

  • Reading time:4 mins read

Don’t you just love when users come up with new feature ideas at a microprocessor clock rate. Even before you finish developing one, five new requests pop up. This is a disease, and it’s called featuritis!

Continue ReadingFeaturitis Cure

Not-so-elementary costing: The Change

  • Reading time:5 mins read

They say the only constant is change. I’d say that the only other constant is error. We humans tend to err. Give a repeatable task to a human, and they’ll mess it up every once in a while. Some call it the human factor.

One of the many repeatable tasks in Microsoft Dynamics NAV is setting up items. If you remember my rant about mandatory fields, and how I said they were baaad, there might be an even more baaad kind of fields: the default value fields. Because the system simply inserts a value into these fields without asking for your say, and if anything is easy, it’s only so easy to overlook these. Yep, you have a chance to voice your oppinion on these, but having got to hurry for a cup of coffe with Mary from accounting, admit it, you’re gonna leave that default FIFO costing method for an item every once in a while, even though it should really have been Average. Then you’ll start posting. Then your phone rings and starts screaming at you about a moron who screwed up items again.

Continue ReadingNot-so-elementary costing: The Change

Silent Abort

  • Reading time:4 mins read

There is only one way to abort a user action in Microsoft Dynamics NAV: by using the ERROR function. This function essentially stops the execution of all code, and prevents completion of the user action, whatever such action might be.

One of typical situations where ERROR is used to prevent user action is during validation of a new value in a field. A typical concrete example of this behavior is entering the Customer No. value in the Sell-to Customer No. field on the sales order form. When users enters a value, the system goes through a series of checks, called validation, which in the end may result in the system rejecting this value. Obviously, the only way for the system to reject a value entered by the user is, yes you’ve got it, by calling the ERROR function, which returns the system to the last committed state before the error.

Continue ReadingSilent Abort