Category Archives: NAV2018

Unable to compare operands of type …

Strange, I added a field to a table, everything compiled. But when modifying a record in the table I’m met with the following error:

Unable to compare operands of type NavCode with NavInteger?

This was in a NAV2018, late CU.

I have seen this kind of error before, usually because of objects not in sync (compiling everything will solve that)

The only change made, was that I added a single Text field.

The error is catch after the OnModify trigger. It’s not a debuggable piece of code that generates the error.

After several failed attempts to locate the source, I delete the field, recompiled everything, and added it again. Then everything worked?

Strange Day 🙂

p.s. Next time I’m gonna check the generated C# code …



There is a syntax error in a whitespace?

Today I was doing my daily dose of hacking, in this case, generating Javascript code from C/AL (Don’t ask). I had copy-pasted some Javascript into C/AL, converted it into strings and was met with this error when compiling:

A closer look quickly determined there’s NO syntax error, so what’s wrong?

The red line is kinda wide, and using some shift-cursor keys movement showed that this is one character:

But that is two spaces?

Ahh, mystery bug solved. You can paste TAB characters into C/AL, and they stay as tabs, but the compiler does not like them. Typing a tab gets translated into spaces, but not if you paste it in there, it just looks like 2 spaces but stays as one tab, that cannot be compiled.

Ctrl-H can actually search and replace the tabs with spaces, by copy’pasting the tab into the Find What field:



Let NAV use TLS1.2 when talking to webservices

Lots of web service vendors these days are tightening their requirement security protocols, SSL was removed back on the hearthbleed days, and not TLS version 1.0 and 1.1 are getting outed too. So suddenly NAV code that has been working for years stop working unless you change your client to select TLS1.2. Thankfully, there is a simple trick to choose the security protocol used by DotNet. This is done with the ServicePointManager.SecurityProtocol property:

Set it to SecurityProtocol.Tls12

Now you’re talking Tls12 with DotNet from inside NAV.

Wikipedia article on TLS