Book Image

Microsoft Dynamics NAV Development Quick Start Guide

By : Alexander Drogin
Book Image

Microsoft Dynamics NAV Development Quick Start Guide

By: Alexander Drogin

Overview of this book

Microsoft Dynamics NAV is an enterprise resource planning (ERP) software suite for organizations. The system offers specialized functionality for manufacturing, distribution, government, retail, and other industries. This book gets you started with its integrated development environment for solving problems by customizing business processes. This book introduces the NAV development environment – C/SIDE. It gives an overview of the internal system language and the most essential development tools. The book will enable the reader to customize and extend NAV functionality with C/AL code, design a user interface through pages, create role centers, and build advanced reports in Microsoft Visual Studio. By the end of the book, you will have learned how to extend the NAV data model, how to write and debug custom code, and how to exchange data with external applications.
Table of Contents (10 chapters)

Managing NAV installation with NAV the Administration Shell

The Dynamics NAV Administration Shell is an alternative to MMC. This is a command-line interface that will be familiar to system administrators. Although the graphical interface is easier and more intuitive, the undoubted benefit of the command-line shell is its ability to combine separate commands into complex batch scripts to automate daily administrative tasks.

Creating a NAV Server instance with Administration Shell

To be able to manage NAV server instances, the Administration Shell must be executed with local administrator credentials. In order to do this, select Dynamics NAV Administration Shell in the Windows Start menu, right-click on the application icon, and choose Run as administrator. The Administration Shell will list available commands on startup. NAV Administration Shell is actually a PowerShell command window, and each NAV administration command is a PowerShell cmdlet. With PowerShell functionality, you can get the same list of commands with the Get-Command cmdlet:

Get-Command -Module Microsoft.Dynamics.Nav.Management, Microsoft.Dynamics.Nav.Apps.Management

In the previous section of this chapter, we created a server instance through an MMC snap-in. The same can be done with the New-NavServerInstance cmdlet in the NAV Administration Shell:

New-NAVServerInstance
-ManagementServicesPort 7055
-ClientServicesPort 7056
-SOAPServicesPort 7057
-ODataServicesPort 7058
-
DeveloperServicesPort 7059
-DatabaseServer localhost
-DatabaseInstance NAVDEMO
-DatabaseName "NAV 110 Test Database"
-ServerInstance NavTestServer
-ClientServicesCredentialType Windows

Note that we provide all parameters, including TCP ports and the database name. Unlike the GUI approach, there is no need to modify server settings after creating an instance.

Managing the NAV server with the Administration Shell

Now the brand new service must be started. To start it, run the following command in the Administration Shell:

Start-NAVServerInstance -ServerInstance NavTestServer

The same can be done with a Windows system cmdlet, Start-Service:

Start-Service -Name 'MicrosoftDynamicsNavServer$NavTestServer'

Note that, in this case, we must provide the full-service name, which includes a prefix, MicrosoftDynamicsNavServer$. When we operate with cmdlets developed specifically for NAV Administration Shell, we only provide the NAV server instance name to the command. The actual server name always begins with the same string, which is implicitly added to the parameter by NAV cmdlets. Keep this in mind when you develop your own Powershell code and pass service names between NAV and system cmdlets.

When you no longer need the additional server instance, delete it with the Remove-NAVServerInstance cmdlet:

Remove-NAVServerInstance -ServerInstance NavTestServer

There are some other cmdlets available in the NAV Administration Shell that can simplify your daily administration activities.

If you are already familiar with Windows Powershell, you probably know about a very powerful cmdlet, Get-WmiObject, that can retrieve information about available Windows Management Instrumentation (WMI) classes. For example, with Get-WmiObject, you can list all installed NAV services:

Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -imatch "DynamicsNAV"}

Services will be listed, along with their state and some other properties.

The NAV Administration Shell provides a shortcut for this command. Get-NAVServerInstance will yield the same result, displaying a list of available NAV services.

With the PowerShell pipeline, the resulting list can be filtered. For example, here is the command to select only running services:

Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"}

Or this is the same without the explicit call to Get-WmiObject:

Get-NAVServerInstance | Where-Object {$_.State -eq "Running"}

Now the result set returned by the previous cmdlet can be sent to the pipeline to stop all running services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} | Stop-Service

Now start all stopped services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} | Start-Service

Then restart all running NAV services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} |
Restart-Service