I was busy writing some code for a blogpost (not this one) and while testing it, I ran the wrong codeunit and got an error I didn’t expect. Then I noticed that the codeunit I ran was the wrong one.
Immediately after that it hit me that the error was really weird because it was generated by a statement in my C/AL code that expected a value. That value should have been passed by the record-parameter of the codeunit.
Running it immediately from the developer environment I don’t pass any parameter, so I should have received this error (like I have seen so many times I my life (generated this error on NAV2009R2 classic with a codeunit named “Do I need a record-parameter?” ) ):
Microsoft Dynamics NAV Classic
The codeunit Do I need a record-parameter? must be called with a Item Ledger Entry record.
So I tried the debugger just to be sure, and indeed the code was running until it hit the error caused by the missing parameter.
So back to NAV2009R2 to be sure of the error it should generate. Indeed I got the error.
Back to NAV2013R2. Ran the codeunit that receives a parameter and it didn’t give an error but just ran the code (just a MESSAGE(‘Ok’); in it…). But it ran!
Tried also on NAV2016 and also there it ran without error.
Tried also on NAV2013 and also there it ran without error.
Didn’t test NAV2015 but I suppose it will work there too.
Last test to be sure: checking my bedroom to see if I wasn’t still sleeping and dreaming. Nop. I am awake!
Starting with NAV2013, a codeunit that has a parameter in the OnRun-method can also be run WITHOUT giving the parameter! The parameter-record will be empty when entering the OnRun-method.