Learning about using “Reason Code” in Dynamics NAV 2009

As Dynamics NAV 2009 has been around for some time already, I thought it would be nice to refresh some of the certifications I’ve got for Dynamics NAV (version 4 is getting out of date a little bit, isn’t it)? Therefore, I started reading through “Finance in Microsoft Dynamics NAV 2009” training materials and to make things more interesting, I was trying to give myself a few questions after every chapter I’ve read.

And the funny thing is that (that’s why asking questions makes things more interesting), I had to stop at the first chapter where I have read about reason codes. At first, simple explanation “Reason codes are used to indicate why an entry was created. For example, if items from a sale must be returned, a reason code is set up to mark the reason, such as damaged, wrong color, or wrong size.” seems reasonable enough. However, if you ask yourself (or if you imagine, your client asking you) more meaningful questions: where do you enter it, how do you do that, where does it get posted, how do we analyze posted reason codes, etc, etc, you need to start digging deeper. Training course materials would not be able to answer all of these questions… Of course, you could you ask your instructor if you were on a instructor led course, but what if you are just skimming through training materials yourself?

Obviously, first thing that springs to mind – let’s google it, let’s go through mibuso, dynamicsuser, blog posts, etc. In 5 minutes I was not able to find an answer that would satisfy my curiosity, therefore I decided to have a look at Dynamics NAV source code myself.

However, I did not have a developer toolkit installed on my laptop and did not plan to do it in the next few minutes, I needed a faster solution. Which I found (remember, I mentioned googling around, skimming through mibuso and dynamicsuser forums, and recent blog posts?) thanks to a blog post: “Where Used” as simple as you can get it.

So… I have quickly downloaded Dynamics NAV W1 5.0 upgrade toolkit. Exported all CRONUS UK objects to txt file. Typed in command line findfunc “Reason Code” CRONUSUK.txt ReasonCode.txt and in few seconds I had a better understanding of reason codes than I could have had on a instructor led course. It is so much better to find an answer yourself. It might take a longer time… but you are not giving a fish for yourself, you are teaching yourself how to fish.

What Version of SQL Server Am I Running?

How often do you find yourself thinking “what version of sql server am I running?”. I bet, it happened more than once… If so, you might find this what version of sql server am I running query quite useful:

SELECT substring(@@VERSION,1,26) + ' (' + -- Full SQL Version
+ CAST(SERVERPROPERTY('productversion') AS VARCHAR) + ') - ' -- SQL Version Identifier
+ CAST(SERVERPROPERTY('productlevel') AS VARCHAR) + ' (' -- SQL Service Pack Number
+ CAST(SERVERPROPERTY('edition') AS VARCHAR) + ')' AS [SQL Server Details] -- SQL Version Type

How to select more than 1 record on LookUp form?

How to Select More Than One Record On LookUp Form

I’ve seen quite a few modifications for Dynamics NAV, where users would select a few records on the list form and then would do something with them (for example, you could print selected invoices to PDF files, you could add selected items to the sales order , etc. I guess, only developer’s imagination is end-user’s limit in functionality). And from end-user perspective this is really a treat – instead of adding twenty different items on the sales order separately, you could do that in one go.

As it is weekend again (and the book I have started reading last week, today is somewhere in India), I decided to play around a little bit. How hard (or easy) can it be?  After playing around for a few minutes I came up with:

// NAVISIONARY 22/11/2009 >>

   SelectedRecord := MyRecord;
   IF NOT SelectedRecord.FINDFIRST THEN BEGIN // if no records were selected
      FormMyRecordList.GETRECORD(ActiveRecord); // select active record
      MESSAGE('No recors were selected, but we still can use active record');
   END ELSE BEGIN // if at least one item was selected
         MESSAGE('Some items were selected');
         // do something for each selected record
      UNTIL SelectedRecord.NEXT = 0;

// NAVISIONARY 22/11/2009 <<

But then I remembered, that instead of reinventing the wheel I should have tried using default Navision functionality. We can select more than one G/L Account when we are adding them to account schedules (Function > Insert Account Schedules). Actual code can be found in Codeunit 8 "AccSchedManagement", function InsertGLAccounts().

On the other hand, sometimes it feels good to do something on your own, doesn't it?

Field Numbering in Dynamics NAV

Field Numbering in Dynamics NAV

Last Friday I received recently published “Programming Microsoft Dynamics NAV 2009” book (written by David Studebaker). Thanks Amazon for the quick delivery!

So, my Saturday morning started with a big mug of coffee and David’s book. I would not call myself a newbie anymore when it comes to Dynamics NAV development, however I decided to go through all the book page by page, chapter by chapter. After all, repetition is mother of all learning… repetition is mother of all learning… repetition is mother of all learning… repetition is mother of all learning…

The first tip (which I was already applying instinctively when developing modifications for Dynamics NAV) I found in the book “Programming Microsoft Dynamics NAV 2009” was to use gaps (incrementing “Field No.” by 10) in field numbering. For example, when you are designing a new table called “My Brand New Table”, you should not just create fields:

  • 1 Custom Field No. 1
  • 2 Custom Field No. 2
  • 3 Custom Field No. 3

It is better to use a different approach, and leave gaps between field numbers. Therefore, my table would look more like this:

  • 10 Custom Field No. 1
  • 20 Custom Field No. 2
  • 30 Custom Field No. 3

Field numbering sequence has affect on how data is sorted, and how data is moved from one record to another. Considering that it is really painful at the end of a project to start renumbering fields, as a rule of thumb, it is faster to create new fields in the gaps you have left before.

From my own experience (I am not sure if other developers do that as well), I like to leave even bigger gaps between groups of fields which belong to different projects. Then, my table would look more like this:

  • 10 Custom Field for Project 1
  • 20 Custom Field for Project 1
  • 30 Custom Field for Project 1
  • 100 Custom Field for Project 2
  • 110 Custom Field for Project 2
  • 120 Custom Field for Project 2

I am only into first 50 pages yet, but I have already found something worth thinking about. I am really looking forward to dig deeper. Let’s grab another cup of coffee…

What is your own best practise when it comes to field numbering in Dynamics NAV? Do you have your own system that would be worth sharing with others?

How To Stay On Top Of Dynamics NAV (Navision)

Start Your Day With A Cup of Dynamics NAV
Everyone of us have a morning ritual (even if we do not know about it yet): getting a local newspaper while on the way to work, grabbing a cup of strong coffee (or breakfast tea with too much milk) while trying shake yourself into the working state, pretending you are not sleepy while you are snoozing away on a train in the middle of your commute. Somehow running or any kind of morning exercise is not even crossing my mind while everyone around me in white collars, black suits, polished shoes seem to hurry to their own cubicles.

I also have my own morning ritual which strangely starts with a cup of coffee… and a cup of Dynamics NAV. I love to come early in the office and while no one (or very few people) is around to dig in into the world of Dynamics NAV news. I know there will always be enough of work to do, but maybe today, maybe this morning I’ll find a way of doing it better than yesterday, better than last week, better than last year. Dynamics NAV is rapidly growing, getting bigger, more user-friendly and better, so why shouldn’t all of us?

Dynamics NAV RSS Feeds (Google Reader)
Subscribe to Dynamics NAV | Navision Google Alerts
It was easy in the past (now, I sound like old geek) to search information about Dynamics NAV (Navision). It was really easy, because information was scarce. You could visit most of (or even all) web pages that consisted at least some useful information about Dynamics NAV. However, as product is growing, people surrounding this ERP software are also getting better. A number of really skilled experts are sharing their knowledge with others. Well, even Microsoft guys started blogging and reaching for information seekers. And with a proper list of Microsoft Dynamics NAV RSS feeds, I always (almost) have what to read with my first cup of coffee.

Dynamics NAV Around World (Google Alerts)
It is easy to compile a list of blogs worth reading and stick to it. Which, of course, is a really good starting point. However, in order to keep current with Dynamics NAV, we need to get newest information available. Blogs like NAV Developer, NAV Reporting, NAV UK Team were not there two years ago. Which means there will sprout more useful blogs in the future. And the easiest way so far, to find new sources of information is to use Google Alerts. You set up automatic alerts once, and you get daily (or weekly) dose of news around the web.

Dynamics NAV News Real-Time (Twitter)
Navision on Twitter
Another way of getting real-time news about Dynamics NAV, is to start using twitter. It is amazing what some of the guys sharing information might write in 140 characters! Before starting to build your own list of RSS feeds, or creating your own Google Alerts, maybe you should start following @navision.