Monday, April 6, 2015

Setting Up SSL for Web Services on Dynamics NAV 2009 R2 and Server 2008 R2

Published by Michael Wong on March 31, 2015 - 10:00pm
NOTE: For the purposes of explaining we will be using the port 7047; however, you can use any port configured for your Web Service.
Requirements
·         Existing Microsoft Dynamics NAV Web Services
·         SSL Certificate installed in Personal Certificates
·         Administrative rights to server
Configure Web Service to use SSL
1.     Run notepad As Administrator and open theCustomSettings.config file on the computer where the Microsoft Dynamics NAV Server is installed. The default location is:

“C:\Program Files\Microsoft Dynamics NAV\Service\CustomSettings.config”

2.     Locate the key:

false
">

and change the value from false to true

true
">

3.     Open the Services Snap In by going to Administrative Tools > Services.
4.     Restart the Microsoft Dynamics NAV Business Web Services service.
Import the SSL Certificate into the local computer store
If you already have the Certificates Snap-In, open the certificates Snap In and skip to step 8.
1.     Go to the Start menu and click Run.
2.     Type mmc and click OK.
3.     On the File menu, click Add/Remove Snap-in.
4.     Locate the Certificates Snap-In and click Add.
5.     Select Computer Account and click Finish.
6.     Select Local Computer and click Finish.
7.     Click OK to close the Add or Remove Snap-ins window.
8.     In the left pane of the console, expand Certificates (Local Computer).
9.     Right Click on Personal and click Import.
10.  When the wizard opens click Next.
11.  Browse to your certificate and click Next.
12.  If the certificate has a password enter it and click Next
13.  Select Place all certificates in the following store and click Next.
14.  Click Finish then OK to confirm that the import was successful.
Obtain the Certificate’s Thumbprint
1.     In the Certificates snap-in, expand the Personal folder and select Certificates.
2.     Locate the certificate you wish to use and double-click it.
3.     In the certificate window, click on Details.
4.     In the Details pane, scroll down to find the Thumbprint field.
5.     Copy the text to a text editor and remove all spaces. Save this for later


Figure 1. Certificate window with Details pane displayed and the Thumbprint field highlighted.
 
Configure the server’s Access Control List and the Web Services Port
1.     Open a command prompt window with elevated (administrative) rights.
2.     If the service is already running and configured, you will need to remove its entries.
3.     Run the following command to show all port mappings for the server:
netsh http show urlacl
4.     The system should return a list of ports and you should see one registered to DynamicsNAV:http://+:7047/DynamicsNAV/


Figure 2. The + after the http signifies localhost
5.     You will need to delete all entries associated with the port for DynamicsNAV. In the example above you see both http://+:7047/ and http://+:7047/DynamicsNAV.

Both will need to be removed.
6.     Remove them by using the following command:

netsh http delete urlacl url={your url here}

Replace the highlighted text with the url from the previous command, e.g., http://+:7047/
7.     You will now need to register the service back with a URL using https.  Run the following command to add the base service:

netsh http add urlacl url=https://+:7047/ sddl=D:(A;;GX;;;NS)(A;;GX;;;BA)

If your port is not 7047, you can adjust the URL to your needs. Make sure that the https is set in the url.
8.     Run the following command to register the DynamicsNAV web service port:

netsh http add urlacl url=https://+:7047/DynamicsNAV/ user={your service username}

Replace the highlighted portion with your service user account e.g. CONTUSO\navservices

Notice that to register the base port, I used “sddl,” and for the Web Service Port, I used “user.” You can use “sddl” for both; however, in order to do so, you will need to get the active directory SID of the user. The format will be as follows:

D:(A;;GX;;;{user SID here})
Configure the port to use the SSL Certificate
1.     Verify that the port you wish to use does not already have an SSL certificate assigned to it by typing the following:

netsh http show sslcert
2.     If you see any entry where the IP:port is bound to the same port as your Web Service, you will want to remove it by typing the following:

netsh http delete sslcert ipport=0.0.0.0:{your port here}
3.     Register your SSL certificate to your Web Service port with the following:

netsh http add sslcert ipport=0.0.0.0:{your port here} certhash={certificate thumbnail here} appid={00000000-0000-6002-0022-0000836BD2D2}

Make sure to change the highlighted areas with your appropriate information. The appID is any valid GUID in your system. The example above is the GUID for the NAV Server.
4.     Restart the Microsoft Dynamics NAV Business Web Services service.
5.     Test the service by going to the following address in your web browser:

https://localhost:7047/DynamicsNAV/WS/Services


Wednesday, February 18, 2015

How to open a restored SQL backup in a different Network (pc)

You may have come across situations where you need to open a MS SQL backup file in a new environment. For example, you may have taken the MS SQL Database Backup from your client location. Now you may need to restore it your local pc and open the database using your NAV 2015 client. These are the steps that you need to follow;

  •   Restore the database
  •  Open the following table using SQL Server Management Studio and delete all existing data.  (Obviously, the Windows User Account names available in the tables need not be using anymore)
            Access Control
            User
            User Metadata
            User Property
  •  Setup the new database by configuring the CustomSettings.xml file and run the RTC Client. In  other  words now you can open the database without any issues. You may now create  whatever the new  accounts using your RTC client.

Tuesday, December 2, 2014

How to Kill a NAV Application Server Windows Service

You may have many experiences where you were in need of killing a NAV Application Server or NAV Service Tier Windows Service which has been stuck at stopping. Basically, you may  have wanted to get this done without needing to reboot a server in the middle of the day.
Here’s what you need to do:
Step 1. Find out the Service Name
To do this, go in to services and double click on the service which has stuck.  Make a note of the “Service Name”.
Step 2. Find out the PID of the service
Open an elevated command prompt and type in:
sc queryex servicename

Make note of the PID
Step 3. Kill the PID
From the same command prompt type in:
taskkill /f /pid [PID]


Be careful of what you are killing though.  If you kill a critical windows service you may end up forcing the machine to reboot on it own.

Saturday, June 21, 2014

Dynamics Navision Full User and Limited User Structure

  • Full User 

    Full User licenses provide users full read and full write capabilities to all of the licensed solution functionality through any and all modes of access, including the Microsoft Dynamics NAV Windows client, the Microsoft Dynamics NAV Web client, or any other mode of access including web services. Full User licenses are for users requiring unlimited read and write access. As long as the number of users needing simultaneous access to the solution does not exceed the number of Full User licenses you have acquired, these users are properly licensed for full read and write access to the complete solution functionality.
  • Limited User 

    Limited User licenses provide users full read, but limited write, capabilities to all of the licensed solution functionality through any and all modes of access including the Microsoft Dynamics NAV Windows client. The Limited User license is designed to give customers a lower-cost alternative for extending ERP to users who only require limited access to the Microsoft Dynamics NAV application:
    • Read access to data contained in the solution through any client accessing the application, including but not limited to the Microsoft Dynamics NAV Windows client, the Microsoft Dynamics NAV Web client, and web services.
    • Write access to a maximum of three application tables in the object range 0 – 99,999,999 other than the General Ledger Entry table, through any client accessing the application. Access to the General Ledger Entry Table requires a Full User license.
  • Device Only User 

    Device-only licenses enable a user to connect, provided there is an enabled device available to use. Devices can be full or limited. Device users have either full or limited access, as determined by the device.
  • Windows Group 

    Use this license type to create a Microsoft Dynamics NAV user based on a Windows group. All members of the group inherit permissions for the user.

    Windows Group licensing is a form of license multiplexing. Multiplexing does not reduce the number of user licenses required to access a Microsoft Dynamics NAV solution.
  • External User 

    This license type is specific to individual users of Microsoft Dynamics NAV 2013 R2. External user licenses must not be shared with other individual users. You do not need concurrent user CALs for external users. External users must not use any clients provided by the Microsoft Dynamics NAV 2013 R2 Application Programming Interface (API), such as the Microsoft Dynamics NAV Windows client or the Microsoft Dynamics NAV Web client. External user licenses must not be used for business process outsourcing purposes.


Wednesday, May 1, 2013

Job Queue and NAS in Microsoft Dynamics NAV

This article explains how to configure and use the Job Queue functionality in Microsoft Dynamics NAV together with the Navision Application Server (NAS) to run background tasks automatically, without user intervention.


Background: Job Scheduler vs Job Queue

The Job Queue feature was introduced in Microsoft Dynamics NAV 5.0 as a replacement for the earlier Job Scheduler functionality available in NAV 4.0.

The key improvement with Job Queue is that it allows multiple background tasks to be scheduled and executed automatically by NAV, without requiring a logged-in user. These tasks are executed by NAS in the background based on predefined schedules.


What Is Job Queue and What Is NAS?

Job Queue provides a centralized queue where background tasks are defined, scheduled, enabled, or disabled. Using Job Queue, you can control:

  • When a task starts

  • How often it runs

  • Whether it repeats

  • Whether it is active or paused

NAS (Navision Application Server) acts as the execution engine. It continuously monitors the Job Queue and triggers the defined tasks at the scheduled times.

In short:

  • Job Queue = task definition and scheduling

  • NAS = background task execution


Main Components of Job Queue

The Job Queue functionality is supported by the following system tables:

  • Job Queue Setup (Table 470)

  • Job Queue Process (Table 471)

  • Job Queue Entry (Table 472)

  • Job Queue Response (Table 473)

  • Job Queue Log Entry (Table 474)

The most important table is Job Queue Entry (472), which stores the actual job definitions.


Steps to Use Job Queue with NAS

Step 1: Install Microsoft Dynamics NAV Application Server (NAS)

  1. Install the Microsoft Dynamics NAV Application Server.

  2. Ensure the NAS service is correctly registered in NAV.

  3. Configure the NAS Startup Parameter as:

    JOBQUEUE

This tells NAS to process tasks defined in the Job Queue.

Important:
NAS must always run without any user interface. Any GUI-related code must be disabled.


Step 2: Create Job Queue Entries

To schedule a background task, you must create a Job Queue Entry.

Example: Automating “Adjust Cost – Item Entries”

Suppose you want to automate Report 795 – Adjust Cost - Item Entries.

Before scheduling:

  • Make sure the report does not use GUI elements

  • Use GUIALLOWED() checks where required


Step 3: Define Job Details (Job Queue Entry Card)

Open Job Queue Entry Card (Form 673).

In the General tab:

  • Object Type to Run: Report

  • Object ID to Run: 795

  • Earliest Start Date/Time: First execution date and time

This defines what will run and when it can start.


Step 4: Configure Recurrence

In the Recurrence tab, define how often the task should run.

Example 1: Run every 2 minutes between 8:00 AM and 6:00 PM

  • Set recurrence interval to 2 minutes

  • Define start and end times accordingly

Example 2 (NAV 2013):

Run Adjust Cost – Item Entries at 2:00 AM on weekdays only:

  • Set execution time to 2:00 AM

  • Select Monday–Friday

  • Exclude weekends


Step 5: Activate the Job

Once all details are defined:

  • Click Set Status to Ready

This marks the job as active and eligible for execution by NAS.


Step 6: Enable Job Queue Processing

Open Job Queue Setup (Form 670).

  • Ensure Job Queue Active is selected

If you need to temporarily stop all background jobs, simply clear this checkbox.


Summary

The Job Queue combined with NAS allows Microsoft Dynamics NAV to:

  • Run reports and codeunits automatically

  • Execute tasks without user login

  • Schedule recurring background processes reliably

This functionality is essential for automation scenarios such as:

  • Cost adjustments

  • Data synchronization

  • Periodic batch jobs

  • System housekeeping tasks

Understanding Job Queue and NAS is critical when maintaining legacy NAV systems and during upgrades to newer platforms.




How Job Queue and NAS Work Together (Visual Explanation)

The diagram above illustrates how Job Queue and Navision Application Server (NAS) work together in Microsoft Dynamics NAV to execute background tasks automatically, without user interaction.


Step-by-Step Flow Description

1️⃣ Job Definition (Job Queue Entry)

The process begins when a job is defined in the Job Queue Entry table.
Here, you specify:

  • Object Type (Report / Codeunit)

  • Object ID

  • Start date and time

  • Recurrence rules

  • Status (Ready / On Hold)

This defines what should run and when.


2️⃣ Job Queue Setup Validation

The Job Queue Setup determines whether background processing is enabled globally.

  • If Job Queue Active = TRUE, processing continues

  • If disabled, no jobs are executed, even if they are marked as Ready


3️⃣ NAS Monitors the Job Queue

The Navision Application Server (NAS) runs continuously in the background with the startup parameter:

JOBQUEUE

NAS periodically checks the Job Queue for:

  • Jobs marked as Ready

  • Jobs whose Earliest Start Date/Time has been reached

  • Jobs matching the defined recurrence rules


4️⃣ NAS Executes the Job

When a job is due:

  • NAS triggers the specified Report or Codeunit

  • The execution happens without any user interface

  • All GUI-related logic must be suppressed using GUIALLOWED()

This allows NAV to run batch jobs safely in the background.


5️⃣ Job Processing and Logging

During execution:

  • Processing details are written to Job Queue Process

  • Execution results are recorded in Job Queue Log Entry

  • Success, warnings, or errors are logged for review

If an error occurs, the system records the failure and may retry based on configuration.


6️⃣ Recurrence Handling

If the job is recurring:

  • NAS calculates the next run time

  • The Job Queue Entry remains active

  • The cycle repeats automatically

If the job is one-time only:

  • It completes and stops unless reactivated manually


High-Level Summary (One-Glance Understanding)

Job Queue Entry ↓ Job Queue Setup (Active?) ↓ NAS (JOBQUEUE) ↓ Execute Report / Codeunit ↓ Log Results ↓ Next Run (if recurring)

Why This Architecture Matters

This design allows NAV to:

  • Automate heavy processing tasks

  • Run jobs outside business hours

  • Eliminate dependency on logged-in users

  • Centralise scheduling and monitoring

It is especially critical for:

  • Cost adjustment jobs

  • Data synchronisation

  • Period-end processing

  • System maintenance routines


Important Note for Business Central Upgrades

While NAS is specific to classic NAV, understanding this flow is essential when upgrading to Business Central, where similar functionality is handled by:

  • Job Queue Dispatcher

  • Server task scheduler

  • Background sessions



Wednesday, January 9, 2013

xp_ndo_enumusergroups and xp_ndo_enumusersids


Dynamics NAV requires two extended stored procedures from xp_ndo_x64.dll to exist on SQL Server. In the case of these procedures are not found in the SQL Server, you will end up receiving an error message when trying to log on using Windows Authentication:

Here is the solution;
STEP 1:
Manually copy the relevant file from the Product CD to the path given below depending on the Windows version you are running.

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn

STEP 2:
Run the below scrip file on the SQLQuery Screen. Please note that the below scripts refer to windows 64 bit version. Therefore, if you will be required replace the xp_ndo_x64.dll with xp_ndo.dll


USE master
EXEC sp_addextendedproc xp_ndo_enumusersids, ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\xp_ndo_x64.dll’

GO
GRANT EXECUTE
ON [xp_ndo_enumusersids]
TO PUBLIC
GO

USE master
EXEC sp_addextendedproc xp_ndo_enumusergroups, ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\xp_ndo_x64.dll’
GO

GRANT EXECUTE
ON [xp_ndo_enumusergroups]
TO PUBLIC
GO

Monday, December 10, 2012

How to kill idle users from NAV server

There are instances where you may be asked to find an easy method for removing the idle users from the NAV database. There has been a well known method where you write a NAV report object to check the idle time of each user and delete the session id by checking their idle time. Then you schedule the NAV report through Navision Application server (NAS).

However, this is an alternative method; in this way, you write a SQL script and schedule it through SQL Job, in the same way you schedule your maintenance plans in your SQL Server such as making daily backups, truncating log files etc.

SQL Script :
USE MyDatabase
 DECLARE @EXECSQL varchar(max)
 SET @EXECSQL = ''select @EXECSQL = @EXECSQL+ 'Kill ' + Convert(varchar, [Connection ID]) + ';'
 From Session WHERE [Application Name]='Microsoft Dynamics NAV Classic client' and [Idle Time]>3000
 EXEC(@EXECSQL)

How to schedule the above SQL Script:
Just enable a job. It’s a matter of pasting the code and give the date & time etc. This is similar to Windows scheduler as well.

Steps for scheduling via a SQL Job:
1.        Expand the SQL Server Agent node and right click the Jobs node in SQL Server Agent and select 'New Job'

2.        In the 'New Job' window enter the name of the job and a description on the 'General' tab.

3.       Select 'Steps' on the left hand side of the window and click 'New' at the bottom.

4.       In the 'Steps' window enter a step name and select the database you want the query to run against.

5.       Paste in the T-SQL command you want to run into the Command window and click 'OK'.

6.       Click on the 'Schedule' menu on the left of the New Job window and enter the schedule information (e.g. daily and a time).

7.       Click 'OK' - and that’s done!!


Special Note: I just thought of posting this into the blog even for own future references. Thanks very much Isuru (Isuru Dias) for letting this to me.

Business Central SaaS Extension Design: Implementing Plant Tracking with AL Event Subscribers

  Extending Business Central SaaS: Plant Tracking Using AL Extensions  1️⃣ Problem Statement In many manufacturing and service-oriented or...