Bug theater in Web services #1

  • Post category:Development
  • Post comments:1 Comment
  • Reading time:3 mins read

imageIf something, Stratus has taught me how buggy the implementation of Web services in Microsoft Dynamics NAV is. Let me be clear from the onset: Web services are a great functionality in NAV, one of the best additions (together with .NET interop) to NAV stack in a long while. But it’s buggy.

Being buggy doesn’t mean it doesn’t work. It only means you need to twist and bend your code to achieve things which you would expect to work out of the box. During development of Stratus, we had to make a series of workarounds in Web services to achieve simple goals, and I decided to share those bugs (and workarounds) with you, to help you be more productive in your Web services based projects.

So, here we go for bug #1: lowercase codes in primary key.


Check this out:

Customer_Service svc = new Customer_Service();
svc.UseDefaultCredentials = true;
Customer cust = new Customer { No = "test" };
svc.Create(ref cust);


(I assume I don’t need to give details about how to configure the Web reference in C# or how to expose page 21 Customer Card as a Web service called Customer.)

 Now, imagine you write this code in your OnRename trigger in table 18 Customer:
ERROR('Gotcha %1!',"No.");


Guess what happens?

Well, you get the ‘Gotcha!’ error. Inserting a lowercase value into a code field actually first insert the lowercase value, then renames it to an uppercase value. Pretty cool, eh?

Funny thing – this cannot be done through RTC. OnRename never gets triggered if you insert a lowercase code value to a key field through RTC. This is how Web services should actually behave as well.


Not much you can do here. Make sure you uppercase your codes before shipping them over to NAV. RTC seems to do just that.


Vjeko has been writing code for living since 1995, and he has shared his knowledge and experience in presentations, articles, blogs, and elsewhere since 2002. Hopelessly curious, passionate about technology, avid language learner no matter human or computer.

This Post Has One Comment

Leave a Reply