How to: Get field values from dynamically loaded tables

If you need field values from different tables at runtime within the same function, then there is a nice solution:


// variables
tableType, Option : CompInfo,PayTerm
result : ARRAY [5] OF Variant 

LoadDynamicallyFieldValues(tableType::CompInfo, result);
MESSAGE(FORMAT(result[1])+', '+FORMAT(result[2])+', '+FORMAT(result[3]));
LoadDynamicallyFieldValues(tableType::PayTerm, result);
MESSAGE(FORMAT(result[1])+', '+FORMAT(result[2])+', '+FORMAT(result[3]));

LoadDynamicallyFieldValues(tableType : 'CompInfo,PayTerm';VAR result : ARRAY [5] OF Variant)
CASE tableType of
  recID := compInfo.RECORDID;
  recID := payTerm.RECORDID;
  GetFieldValue(recID,'Discount %',result[3]);

GetFieldValue(recID : RecordID;fieldName : Text;VAR fieldValue : Variant)
 fieldRef := recRef.FIELD(field."No.");
 fieldValue := fieldRef.VALUE;



MVP Award part 2 … more or less


Got mail … not from Microsoft, but from FedEx …


So, what does that mean ? Do i get my 2. MVP Award ? A bit Yes and a little bit more of a No. After clarification with Cristina Herero (MVP Program Manager Europe) will MVP Awards given on Oct/16 or later – normally valid for one year, then the candidate will be reevaluated – be extended til July/2018. Veeeery strange, does not feel like a real MVP Award and it’s a bit unfair. But we have to accept that.

All of that because of the changes in the MVP Award Renew Cycle some of us new MVPs get that info in that way.

Like last time: Many, many thanks to my girlfriend for supporting me for so many years in so many ways, bringing light, love and friendliness into my life.

Many thanks to the readers of my Nav blog and the members of the Nav community.


How to try out Dynamics 365 Financials in countries, where it’s not official published

In countries like Austria Dynamics 365 Financials is not official published. Therefore people in these countries cannot try it out using there local business email account, they cannot learn, how to use it, cannot write postings about Dynamics 365 topics. Also to be an Dynamics NAV MVP does not help here. It would be nice, if Microsoft finds an official solution for that issue. 

I asked MVP colleague Steven Renders, how this could be done and short time later he published a real cool tutorial.

You start with an O365 Account. With that international official business email account you can start to register for all Dynamics 365 apps.

For the whole posting follow this link.

Get next object version number

Every developer has sometimes the issue: What is my next version number for the new object ? If there is a couple of developers working in the some database, you’ll need a kind of a version control.

I’ve developed a page, which calculates the next version number for a defined version prefix. The version sytax is: <PREFIX><Main No.>.<2-digit Sub No.>.

Let’s start with a list of pages with different version list, version ARCH1.00 to ARCH1.06. It does not matter, if the version list of an object contains more than one value.


After running the page set the version prefix, here ARCH, and push action “Get next version”. We get then the new version: ARCH1.07.


You can download the page here.


Export Nav Objects by Code

Exporting locked nav objects can be a problem when importung in target database. it’s not that easy to unlock them in the target database. So for that you can export nav objects by code and check Lock status before exporting.

Create a new report, add dataitem Object. set report to processingonly.


select dataitem Object, set property ReqFilterFields to Type,ID.
set request page: add field Path (Text).


add following code to trigger OnOpenPage:

Path := 'c:\temp';

add following code to report trigger OnPreReport():

finsql := 'C:\Program Files (x86)\Microsoft Dynamics NAV\100\RoleTailored Client\finsql.exe';
  ERROR('finsql not found');

additional add that code to trigger Object – OnAfterGetRecord():

IF Object.Locked THEN BEGIN
  Message(FORMAT(Object.Type)+'-'+FORMAT(Object.ID)+' is locked.');
  // alternatively unlock object, then try again.
  // Object.Locked := FALSE;
  // Object.MODIFY;
end ELSE begin
  arguments := 'command=exportobjects,file=%1,servername=%2,database=%3,filter="Type=%4;ID=%5",ntauthentication=1';
  arguments := STRSUBSTNO(arguments,Path+'\'+FORMAT(Object.Type)+'-'+FORMAT(Object.ID)+
  result := result + FORMAT(Object.Type)+'-'+FORMAT(Object.ID)+'\';

to trigger Object – OnPostDataItem():


Global Variables:

Process DotNet System.Diagnostics.Process.'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
arguments Text
finsql Text
Path Text
result Text


How to: Get record count for all tables

In newer Nav versions the tables overview in development environment/database information has gone. So how to get that list back ?

Let’s got to SSMS (Sql Server Management Studio).
There select the database, for which you want that information.
Right click on database -> Reports -> Standard Reports -> Disk usage by Top Tables

enter image description here

There we are ! 😉


How to: Create an automation for usage in Navision

The development of a COM component with .Net for usage in Navision needs a special approach. Start with a new C# project, project type Class Library. Set the project to “Make assembly com-visible”. The simple automation provides a string property and a method to show a .net message box.

// a sample code
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace SampleAutom
 // the interface, so that the methods and properties are shown in Nav
 // needed attributes InterfaceType and Guid
 // create a new Guid
 interface IMyInterface
  // set a DispId for each method/property
  int MsgBox(string message);

  string Title { get; set; }

 // class attributes
 // implement the interface
 public class TestCom : IMyInterface
  string _title = "Dynamics Nav";

  public TestCom()
  { }

  // with property Title you can set/read the title of the msgbox
  public string Title
    { return _title; }
    { _title = value; }
  // method msgbox returns an integer value according the clicked button
  // Yes = 6, No = 7, Cancel = 2
  public int MsgBox(string message)
    var result = MessageBox.Show(message, Title, 
       MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
    return (int)result;

To install the new automation run visual studio in admin mode. after restart and loading the project build/compile the project.

Now start Navision and create a new codeunit. In the OnRun trigger add following code:

// TestCom, Automation, 'SampleAutom'.TestCom 
// RetVal, Integer 
TestCom.Title := '.Net Msgbox run in Navision';
RetVal := TestCom.MsgBox('Your message text ...');

Now run the codeunit. It results in:

autom1    autom2