HOW TO set NAV Service Startup Type via PowerShell

When you create a new Instance using the command New-NAVServerInstance it will set the Startup Type of the NAV Service as “Automatic” by default.

I haven’t found any NAV command to change it, so let us think about NAV Service as any other Windows Service.

In PowerShell there is a command Set-Service that allows to change an existing Service.

NAV Service names have the following format


where <ServerInstance> is the name of the NAV Instance

So running the following command we can change the Startup Type to Automatic, Manual or Disabled.

Set-Service –Name "MicrosoftDynamicsNavServer`$DynamicsNAV100" –StartupType Manual

This example will set the NAV Service for the Server Instance DynamicsNAV100 to Manual.

Unfortunately -StartupType parameter does not have a value for Automatic (Delayed Start)

So it seams a bit tricky but just looking into the register I’ve noted that the other services that had Automatic (Delayed Start) as Startup Type have a REG_DWORD value called “DelayedAutoStart” with value 1 under HKLM\System\CurrentControlSet\Services\

So the idea is use the previous command to set the Startup Type to Automatic then add REG_DWORD via script

Set-Service –Name "MicrosoftDynamicsNavServer`$DynamicsNAV100" –StartupType Automatic
Set-ItemProperty -Path "Registry::HKLM\System\CurrentControlSet\Services\MicrosoftDynamicsNavServer`$DynamicsNAV100" -Name "DelayedAutostart" -Value 1 -Type DWORD

In reality we could setup everything from the registry

Set-ItemProperty -Path "Registry::HKLM\System\CurrentControlSet\Services\MicrosoftDynamicsNavServer`$DynamicsNAV100" -Name "Start" -Value 2 -Type DWORD
Set-ItemProperty -Path "Registry::HKLM\System\CurrentControlSet\Services\MicrosoftDynamicsNavServer`$DynamicsNAV100" -Name "DelayedAutostart" -Value 1 -Type DWORD

NOTE 1: Both scripts will work only if the current Startup Type is different of Automatic
NOTE 2: “DelayedAutostart” DWORD will have effect only if you setup the Service Type as Automatic.

Did my HOW TO help you? Leave a reply.

HOW TO run SQL query for multiple companies in NAV database

In Micrososoft Dynamics NAV, tables with property DataPerCompany = No are stored in SQL in multiple tables having the company name as prefix, than $ and the name.

Example, the Customer table in Cronus Company:

CRONUS UK Ltd_$Customer

The following T-SQL Script retrieves the list of the companies, loop through them and use the Company Name as prefix (@pref) to run a query (@sql_ext).

DECLARE @pref nvarchar(30)
DECLARE @sql_ext nvarchar(max)

DECLARE company_cursor CURSOR FOR 
SELECT replace(Name,'.','_') FROM Company

OPEN company_cursor
FETCH NEXT FROM company_cursor INTO @pref 


SELECT @sql_ext = N'SELECT * FROM [dbo].[' + @pref + '$Inquiry Note] WHERE DATALENGTH([Note]) < 4'

EXEC sp_executesql @sql_ext
FETCH NEXT FROM company_cursor INTO @pref 

Here find another reading suggestion, this time in C/AL: HOW TO change data for all Companies in NAV

Did my HOW TO help you? Leave a reply.

You do not have the following permissions on TableData

When we develop in Microsoft Dynamics NAV, we use a Developer License that has permissions to the standard objects different of the license of the final customer.

Using the customer’s license you may encounter error messages as follows:

You do not have the following permissions on TableData {TableName}: {Read/Insert/Modify/Delete}

An example could be running a Codeunit that modify a record in the standard table 6550 Whse. Item Tracking Line.
You do not have the following permissions on TableData

I’m pretty sure that most of you after will receive an error like this, first will search the table number of the one in the error message. Then you will realize that is in the range of the standard objects (e.g. 6550) and you will start thinking why this error didn’t happen during your tests.

Well, the answer is obvious if you think that probably you tested using the Developer license and that the Customer’s license has different permission to access to the standard objects.

Create a new Page using the wizard of type List to show all the fields of the system table Permission Range.
Then run it with the Customer’s license and filter for the object in the error message (i.e. TableData 6550)
Permission Ranges
As you can see, this TableData in the Customer’s license has Insert/Modify/Delete permission as Indirect. This means that you CANNOT do those action directly in that table.

Note: Remind that if you are saving the license in the database or you upload a new license you must restart the instance service.

In the meantime you realized (maybe debugging) that the code that caused this error is in a Codeunit. Bingo!!!

You do not have the following permissions on TableData

Open the Codeunit in design and assign in the Properties the correct Permissions to the tables

Did my solution solve your problem? Leave a comment.

SQL Server upgrade from Express

To upgrade SQL Server from Express edition to a different edition of the same version follow the steps:

  1. Insert the SQL Server installation media of the new edition you want upgrade to. From the root folder, double-click Setup.exe.
  2. SQL Server Installation Center click Maintenance, and then select Edition Upgrade.

Did my HOW TO help you? Leave a reply.

HOW TO gain access to local drives in RDP

Often when you are connected to a computer in a Remote Desktop Connection (RDP) you need to have access to your local drives or local files.

HOW TO gain access to local drives in RDP?

  1. Click Start, point to All Programs (or Programs), point to Accessories, point to Communications, and then click Remote Desktop Connection.
    Remote Desktop Connection
  2. Click Show Options and then click the Local Resources tab.
  3. Click More under Local devices and resources.
    Remote Desktop Connection - Local Resources
  4. Select the check box next to Drives (you could select some drives clicking the plus sign to show detail data) then click OK.
    Remote Desktop Connection - Choose local devices and resources
  5. Click the General tab, Type the name of the Computer and the Username (with format Domain\Username) and then click Connect.
  6. Type your Password and then click OK.

Did my HOW TO help you? Leave a reply.

Working with dates in NAV

To work following the standards avoids future issues.

In this post I’d like to suggest a way to convert dates in NAV.

Working with dates in NAV

A date in your system can have different formats depending on the preferences of your country and language.

You can come across different errors, for example Server and Client with different settings or ambiguous date because valid between two different formats (e.g. 05/04/2015 that could be DD/MM/YYYY or MM/DD/YYYY)

To avoid this confusion there is an International Standard that is the standard XML format that returns the date in the following format


In NAV you can use the FORMAT Function (Code, Text) with the following declaration:

String := FORMAT(Value[, Length][, FormatStr/FormatNumber])

and using the FormatStr = 9 to return a string in XML format


Note: Leaving the Length = 0 then the entire value is returned.

This example requires that you create the following variables:

Name DataType Subtype
varDate Date


varDate := DMY2DATE(5,4,2015);

It will return
Working with dates in NAV

How to convert from a string in XML format back to a field or variable of type Date?

To convert a string in a date in NAV we need to call the EVALUATE Function with the following declaration:

[Ok :=] EVALUATE(Variable, String[, Number])

It’s interesting that also in this function we can use Number = 9 to set that the string expected will be in XML format.

Using the standard XML format you will work in accordance to the standards and the configuration of your Server or Client, language or preference in your system will not affect your work and each date will be converted always in the same manner.

Remind that you can use the same functions and logic working with DateTime.

Did my post help you? Leave a reply.

HOW TO test if a DateFormula variable is empty

We can learn a lot reading Microsoft standard C/AL code.

HOW TO test if a DateFormula variable is empty?

An example is offered in the Table 5088 Profile Questionnaire Line

TESTFIELD("Starting Date Formula",ZeroDateFormula);

Create a Global Variable named like ZeroDateFormula of DataType DateFormula and don’t assign any value to it.

Now you can use this variable to test if a DateFormula variable is empty.

IF PeriodLength = ZeroDateFormula THEN

Did my HOW TO help you? Leave a reply.