Mainpage with action always runs the action on the first record of the subpage

This problem happens on NAV 2013R2 build 37221. I didn’t check the other builds or versions.


Action on Warehouse Receipt (Page 5768) that then calls the warehouse subform ([or should I say Subpage?] Page 5769) because the action does something on the current Warehouse Receipt Line of the subpage.

To make this work, the action calls “CurrPage.WhseReceiptLines.PAGE.SomeAction();” (Here we DO have PAGE!)


In the subpage, I have a function that does the action (calling a codeunit to avoid putting code in the page, but that is another [PRS-]story…).


My story is about the fact that whatever record on the line I choose, the action is ALWAYS run on the FIRST line. How is that possible?


I noticed that in the header, the triggers “OnFindRecord” and “OnNextRecord” have some code in them. The reason is to search a record you can see as a warehouse employee. A filter might be better but again, this is … again … another story. Well, maybe not a good idea if you have some 100 of locations to which you are allowed to use…


So, I thought, I will create a global variable of the same record-type as the page and in the “OnAfterGetCurrRecord”-trigger, I will save the “Rec” into my variable. This is the code:




WarehouseReceiptLineREC := Rec;



And it worked! And strangely also “Rec” now had the correct record.


Now I thought of something  : I just put this code in the trigger:




That’s correct. 1 line with just “//” in it and NO CODE!


But also this worked.

Review:Programming Microsoft Dynamics NAV 2015

After reading also the other “Programming Microsoft Dynamics NAV…”, I was curious about the latest one in the series.

Even if the book is for people starting programming in NAV and I having lots of experience with Navision/NAV (started in 1999), each time I read one of the books I find some things I didn’t know (or did know and forgot about it … ahum).


When I started developing in 1999, I didn’t have the luck to have such a book. I did have a 3-day course in C/AL development but having a book like this would have been a lot better (and cheaper!) to have me started with C/AL.


How should you use the book? Well, definitely not like I did: Reading it by bits and pieces while on the train.

The best way is to first install and prepare NAV2015 on your PC, have a developers license, open the book and start reading and developing and testing. Doing things while you read about it is the best way to learn how to develop!


Some of the parts I like the most:

-”Enter the first field number as 10 (the default is 1), and increment each remaining field number by 10 (the default is 1).” : the defaults are not always the best even if used since the start. It definitely helps being able to put the field “Post Code” near the other address-fields instead of far, far away in another galaxy…

-”INSERT(FALSE);” and not “INSERT;”. “It’s always a good habit to write code explicitly so there is no doubt what the intended action is” : I would call this a no-brainer! Maybe this is the reason I never saw this written before …


And something new I learned (I did learn other [new] things, but this is something I never knew in all this years with C/AL [shame on me!]):

-”RESET function”:” …., and clears all internal variables in the current instance of the record.”. This was something I didn’t know. I always use CLEAR for it. But both have something you need to know to avoid bad surprises: they don’t delete the records in the temptables used inside the current instance of the record!


Definitely a book to read. Even for experienced developers (ok, YOU can read it on the train…).

Review:Microsoft Dynamics NAV 2013 Application Design written by Mark Brummel

Maybe you remember Marks book “Microsoft Dynamics NAV 2009 Application Design”. Well, this book has the same base but it is updated to NAV 2013 R2 (and not just NAV 2013 like the name of the book implies).

This book is for everyone who develops (including analysts, project leaders, testers, …) in NAV. It gives an overview with some examples of all modules in NAV and also some development to add functionality.

Even after working more than 10 years with NAV and reading the previous book, I am still surprised Mark is able to show so clearly how easy it is to add functionality in NAV … And to do it in a correct way!

So why buying this book if you already have the MS NAV 2009 Application Design?

  • More Partner Ready Software and NAV Design Patterns in it (after all they didn’t exist in 2010 when Mark wrote the MS NAV 2009 Application Design).
  • I have to admit that there is a lot of things the same as in the old book but when I put the books together to have an idea of the differences, I found the MS NAV 2009 Application Design book just plain old. The MS NAV 2013 Application Design is NEW!
  • A lot of changes in chapter 9 Interfacing. When I confronted the 2 books, I was surprised to see how much extra possibilities NAV has for interfacing (even if I already used most of them).

Here is a link to the book : Microsoft Dynamics NAV 2013 Application Design $5 EBOOK BONANZA

Shopping time!

Packtpub has a festive season offer: $5 (that’s €4.80 for me) for an eBook or Video!

Check out this website:

NAV TechDays 2014: Installing and configuring SQL Server for NAV

The material of my workshop (including a pdf with the slides) is online:

The NAV2009R2 webservice does not start in time

Yesterday, I had a customer blocked.

What happened?

We imported some objects and restarted the webservice so it would take the new objects. But the webservice didn’t start anymore. (BTW: they still use the classic environment but a lot of data comes by webservice.)

In the event-log, there was nothing from the webservice. Strange.

But I got some other messages stating that some entries in the registry were blocked by the webservice user and had been unblocked by the user login service (or something like that). What the ….????

What is going on?

Problem with the account used for the webservice? Tried another account. Same problem. So, not a problem with the user account.

Is it SQL Server somehow? Changed SQL Server setup and restarted SQL Server to see all logins (failed and succeeded). After a lot of retries to start the servicetier, I rarely got a login from it in SQL Server. So most of the time, the servicetier doesn’t even get to SQL Server.

Firewall, antivirus? Disabled. Still same problem. So this is not slowing down things.

With the strange messages in the event-log, I found that there was a 30-second time-out. But what kind of time-out?

After some duckbingling, I found that the service controller starts a service and that service should communicate to the service controller when it is completely started. If after 30 seconds the service controller doesn’t receive a message from the service, the service controller assumes that the service has failed and KILLS it!

Ahha! Now we have something!

Maybe if I can change that 30-second time-out to 2 minutes, the webservice has enough time to activate itself.

I found this post that helped me how to change the 30-second time-out. In short: I needed to add/change a key in the registry and then restart the server.

Done that. Restarted the server. And TADAAAAAA. The service is up and running and humming.

Doublechecking it inside NAV: I do some logging of webservice processes to see what they are doing and indeed, logs were coming in.

So, did I fix the problem?

No. I didn’t! But I did find a way around it.

The problem is not fixed, because that would mean having the webservice start under 30 seconds.

It is a some problem between the webservice and Windows. But I don’t have the knowledge to find out the problem.


But anyway, if my experience can help someone avoiding to be problem-solving from 17:00 to 22:30, then I would say, it has been a useful post.

Where are my keys?

Ever were searching for your keys? A colleague and me were searching for them once.

BTW: I am not talking about our car-keys or office-keys but about our NAV-keys!

And we found out that when a table is locked in NAV2013 (I didn’t check out NAV 2009R2 and NAV2013R2) by someone. If someone opens the table and wants to check the keys, they aren’t there.

NAV integer table in SQL-statement - improved

Maybe you remember my old post NAV integer table in SQL-statement.

It does work but has some drawbacks: it works well for small tables but get very fast very slow with a greater number of rows.

There are a lot of possible methods that are better. The best (most of the time) is the Itzik-Style Cross-Join.

  E1(N) AS (
           ),                          -- 1*10^1 or 10 rows
  E2(N) AS (SELECT 1 FROM E1 a, E1 b), -- 1*10^2 or 100 rows
  E4(N) AS (SELECT 1 FROM E2 a, E2 b), -- 1*10^4 or 10,000 rows
  E8(N) AS (SELECT 1 FROM E4 a, E4 b)  -- 1*10^8 or 100,000,000 rows
For some other possible ways, I’ll point to the article I read about it.
Hidden RBAR: Counting with Recursive CTE’s

I forgot my administrator password

Ever had this problem? I just did in a virtual machine……

But I got it back using this link :

I hope this is NOT helpful to you because you never need it. In the other case, I really hope it is helpful to you!

SQL Server 2014 and NAV

SQL Server 2014 has gone RTM on the first of April 2014.

For the moment Microsoft NAV has not yet confirmed SQL 2014 as compatible with some NAV versions. I hope they don’t wait too long.

But does it has some goodies that are useful for NAV?

Lets see the top features of SQL Server 2014:

  • Enhanced memory support: Standard Edition supports up to 128GB of memory. For the moment I haven’t even 1 customer that has 64 GB of memory for SQL server (the limit for SQL 2012 Standard Edition). But it might be useful in very large NAV installations.
  • Encrypted backups: I haven’t had a customer that wanted encrypted backups. But it IS Standard Edition!
  • Backup to Azure: Standard Edition : Well this could be interesting. Best practice is to have your backup not on the same physical server (and even less on the same physical disks…) and not even in the same room and even better : not even in the same building. Best would be on another continent (you never now if some meteorite will hit). Well, backup to Azure is the best you can have. In the Microsoft datacenter, you have 3 copies on different servers and if you have GEO redundant storage, you also have a copy in another Microsoft datacenter. Well, Encrypted backups as Standard Edition feature DO have sense now!
  • Delayed durability: Express Edition!: Normally when you COMMIT some data, SQL writes the data in the logfile and then your session is freed up again so you can continue working. Delayed durability keeps the COMMITed data in memory to harden it (=write it to disk) later. Does this ring a bell? The Native NAV database has had this for years! Of course both have the same problem: you COMMITed the data and it hasn’t been written to disk and your server crashes => you lose that data. This feature could be very useful if your transactionlog has performance problems and you can affort some dataloss. For more info :
  • Buffer Pool Extention (only on 64 bit): Standard Edition. If that 128 GB of memory is not enough, and you don’t want Enterprise Edition, you can do something in-between: put an SSD in your server and tell SQL to use it as extra memory with speeds somewhere in between memory-speed and disk-speed. Useful if your DB-size is expressed in TB instead of GB, but not really for NAV.
  • Enhanced Columnstore indexes: Enterprise Edition. Instead of indexing some fields in a table, you index only 1 column. So this index can be compressed very well and be scanned very fast. Very good for DWH. In SQL 2012 they existed but you had to disable the index before you could update the underlying table. Now you don’t need to disable the index anymore. Not really useful for NAV being an ERP and not a DWH. And there was no support for it directly in NAV (and probably it will never be supported). You would need to create/maintain them using TSQL.
  • In-memory tables (the feature is called In-Memory OLTP): Enterprise Edition. OLTP you say? Now it is getting interesting. NAV is OLTP! What are in-memory tables? An in-memory table (and its indexes) is kept in memory instead of on disk. Isn’t that the same as pinning ( a table? No, because pinning still using the same procedures for locks and latches. In-memory tables do not use those. They have their own procedures that are optimized for memory. Don’t worry, the data is still hardened to disk (don’t forget delayed durability), so your data is safe. They do have some limits like no AutoIncrement properties (=IDENTITY in SQL), clustered index is mandatory (is that a limit?), … Indexes are NOT maintained on disk, but only in memory, so when you start your server, it might take somewhat longer because SQL has to create the indexes on-the-fly in memory. Backups are faster,because the indexes are NOT backuped. Very important is that you need to have the memory to keep all that data in memory and keep some memory for the other tables/locking/… . This is a feature that has its uses in NAV, but NAV should support them natively (=using table-properties and NOT directly in SQL!) but it is still an enterprise edition feature. So it is not widely usable in NAV. But still a feature for which I see some cases where I might use it!

To finish, a link to the page where you have all the SQL 2014 features and in which edition you can use them :

Create a new blog and join in the fun!