Application, Area, Development Tips, Extension Package, How To, Information, Library, Machine, Multitenancy, NAV 2017, Notification, Permission, PowerShell, Readiness Library, Series, Tagging, Time, Tip & Tricks, Web Services, What's New

New Changes or features for Developer and IT Pro Changes in Microsoft Dynamics NAV 2017

Although it is too early to discuss on features and capabilities which we are going to get in our new release, we should wait for exact information post release of same.

Here are few extracts from available documents pre-release of the product.

You will find most of the features similar to which we have discussed in our earlier posts for Madeira Preview Project.

New thing is capability of extensions and Web Services are enhanced and programmatically handling Notifications.

 

Extensions

Dynamics NAV 2017 includes many new capabilities for Extensions:

  1. You can now include reports, XMLports, and queries in your extension along with new custom report templates.
  2. Default or initial data for new tables as part of your extension. These data will be included in the package file (.navx) and inserted into the table at the time of installation of the extension.
  3. You can include translated captions and constants for one or more languages by including object language files in the extension package.
  4. A translation only extension could be built that translates strings for base objects or objects for another extension.
  5. You can include and deploy .NET interop types executed on the server, client-side JavaScript or WinForms extensibility control add-ins.
  6. Extension can include a web service and configure it for the tenant the extension is being installed for in a multitenant deployment.
  7. Two new C/AL functions NAVAPP.RESTOREARCHIVEDATA and NAVAPP.DELETEARCHIVEDATA, you can easily restore or delete archived table data during a reinstall or upgrade of the extension.
  8. Use the NAVAPP.RESTOREARCHIVEDATA function to simply copy the data back from the archive table when special upgrade logic is not required.
  9. Use the NAVAPP.DELETEARCHIVEDATA function in situations where you do not want to restore the archived data for the table.
  10. You can publish an extension to a Dynamics NAV Server instance that is configured with an Azure SQL Database using new parameters added to the Publish-NAVApp cmdlet. The new parameters are used to provide the location and credentials for connecting to an existing Azure SQL database you created.
  11. Users with the appropriate permissions in the application can install and uninstall extensions from the Extensions Management page. The page will display all of the extensions that are currently published.

 

Web Services in multitenant deployments

You can publish per-tenant web services in situations where a web service has not been published for all tenants of the service.

You can also package and deploy published web services for base objects or extension objects in an extension.

The packaged web services will be published to the tenant for which the extension is being installed.

 

Notifications in the UI

Dynamics NAV 2017 introduces a programmatic way to send non-intrusive notifications to the UI in the Dynamics NAV Web client.

Notifications provide users with information about a current situation, but do not require any immediate action or block users from continuing with their current task.

In the UI, notifications appear in the Notification bar (similar to validation errors) at the top of the page on which a user is currently working.

Notifications that are defined on sub-pages, for example in parts and FactBoxes, appear in the same Notification bar.

Validation errors on the page will be shown first.

In the development environment, you create notifications in C/AL by using the newNotification and NotificationScope data types and the following functions.

  1. MESSAGE specifies the content of the notification that appears in the UI
  2. SCOPE specifies the scope in which the notification appears, which can be LocalScope or GlobalScope.
  3. A LocalScope notification appears in context of what the user is currently doing, while GlobalScope notifications are not directly related to the current task. Note: GlobalScope is currently not supported.
  4. SEND sends the notification to be displayed by the client.
  5. ADDACTION adds an action on the notification. Actions enable you to create interactive notifications that provide users with different actions that they can take to address the notification, like opening an associated page for modifying data. A notification action calls a function in a codeunit that you define, passing the notification object in the call. You then add business logic to the function for handling the action.
  6. SETDATA and GETDATA set and retrieve a data property value for the notification, which is typically needed when actions are invoked.

The following example illustrates the simplified code for local scope notification that has an action:

VAR

CreditBalanceNotification@1170000000 :Notification;

PROCEDURECreditBalanceCheck@1170000023(Customer@1170000000 : Record 18);

BEGIN

//Create the notification

CreditBalanceNotification.MESSAGE(‘Thecustomer”s current balance exceeds

their credit limit’);

CreditBalanceNotification.SCOPE :=NOTIFICATIONSCOPE::LocalScope;

//Add a data property for the customernumber

CreditBalanceNotification.SETDATA(‘CustNumber’,Customer.”No.”);

//Add an action that calls the ActionHandler codeunit, which you define  in the next step.

CreditBalanceNotification.ADDACTION(‘Gohandle this’,

CODEUNIT::NavExtensionInstallationMgmt, ‘OpenCustomer’);

//Send the notification to the client.

CreditBalanceNotification.SEND;

END;

In the “Action Handler” codeunit, you would add code to handle the action in a global function, called OpenCustomer, which has a Notification data type parameter. You could use the GETDATA function to get the value of the data sent with the notification:

PROCEDUREOpenCustomer@1170000024(theNotification@1170000000 :

Notification);

VAR

CustNo@1170000001 : Code[20];

BEGIN

// Do the code to handle the action.Optionally retrieve data carried by

the notification.

CustNo :=theNotification.GETDATA(‘CustNumber’);

// …

END;

 

Setup data in the US version

The US version of Dynamics NAV 2017 includes two RapidStart packages that will enable a fast implementation for a new company.

These data packages come with a new Windows PowerShell script to upload to server – and can be enabled for new companies.

Create a new company in the Companies page, and choose the Enable assisted setup field.

Then, use the Import-NAVConfigurationPackageFile cmdlet to import the RapidStart packages.

Then open the new company, the packages are applied, and you will be taken through an assisted setup experience.

 

Application area tagging

The Application Areas system offers developers, administrators, and users the ability to define differentiated user experiences according to application scope.

By selecting a set of application areas, users only see UI elements that are specific to the application features that they need to perform their tasks.

When companies want to create differentiated user experiences, the Application Areas system should be considered as an option not compulsory to adopt.

 

Time series library

One of the most popular topics for machine learning is forecasting based on historical data.

Many algorithms are there that can do this, but you do not have to know them, because MS have wrapped them for us.

Five of these algorithms, are wrapped in one Azure ML experiment, added logic that compares different results and returns the best one accompanied by an indicator of the prediction’s quality.

There is also a generic API on top of this that allows Dynamics NAV developers create their own functionality that helps customers find the business-critical information that may be hidden in their database.

You can perform time-series analysis in the familiar development environment.

The time series library is used by the Sales and Inventory Forecast extension.

 

Source:- https://mbs.microsoft.com/Files/partner/NAV/Readiness_Training/ReadinessTrainingNews/WhatsNewDynamicsNAV2017LimitedBeta.pdf

I will come up with more details in my upcoming posts.

 

 

Advertisement
Cues, Data, Development Tips, Dynamics 365, Email, Extension Package, Functional Tips, How To, Information, Inventory, Job, Machine, Maderia, Multitenancy, NAV 2017, Office 365, Office Integration, Readiness Library, Server, Tip & Tricks

New Changes or features for Application Users in Microsoft Dynamics NAV 2017

Although it is too early to discuss on features and capabilities which we are going to get in our new release, we should wait for exact information post release of same.

Here are few extracts from available documents pre-release of the product.

You will find most of the features similar to which we have discussed in our earlier posts for Madeira Preview Project.

 

Incoming documents

New modification to the list of incoming documents. Now it will have filtered view, a new field Processed is added, and now by default filter is applied to show only unprocessed incoming documents in the list.

However you can choose to still view all incoming documents in the list using the show Show All action.

When documents are posted, the processed flag is set to Yes, such that incoming documents that have been processed into posted documents are filtered out.

Capability is added to manually switch the Processed flag.

Now OCR supports for document extracting line details, when we send PDF or image files on incoming documents to Lexmark ICS, the 3rd-party provider of OCR services.

You can now create purchase invoices with multi-line details.

Now you can easily correct OCR errors before receiving the document and at the same time configure the service to avoid the known errors in future.

You can use the new Lexmark ICS online experience to visually train and validate the OCR processing of PDF and image files for incoming documents, such as vendor invoices.

From each incoming document record, you can now link directly to the online extracted document to validate the OCR result and train the service with your corrections.

A new Role Center Cue will give users capability to monitor incoming documents that await your OCR validation.

 

 

Inventory Items

Item attributes similar to one we saw in Madeira.

Capability to add attributes to your inventory items will make it easy for you to find the right product that your customer wants by filtering on attributes.

You can define your own attribute types, such as Base Material, Colour, Size, or other product dimensions, and attach to your items as a supplement to the built-in item attribute types and values.

When you access your items on documents or list, you can view and filter on the attribute values to limit the list of items.

By using Categorize items you can create a hierarchy of item categories and assign item attributes to each item category.

When you add items to a category, they will inherit the default attributes on the category.

This will ensures to have a common set of attributes on related items, will speed up the assignment of attributes to similar items, and allow filtering and navigating related items easily based on the category.

 

 

Smarter sales and purchase documents

Now you can cancel posted sales and purchase credit memos in the same way like you can do for posted sales and purchase invoices.

After performing this action you will find the credit memo is unapplied from the invoice and creates a new invoice that is applied to the credit memo.

This action will bring you to the earlier position where you created the credit memo. (Like Undo)

Package Tracking No. and Shipping Agent Code on sales invoices Posted sales invoices now show the package tracking number and the shipping agent code by default.

 

Account Categories in the Chart of Accounts

A new capability is added as account categories and sub categories.

Now you can group G/L Accounts to adjust your need for financial reporting.

For each G/L account, now you can specify the account category so that when ledger entries are posted to these accounts they are categorized as per your category.

For each account category, you can now choose from different sub-categories, even you can also create new sub-categories as per your need.

For example, for the G/L account category Expense, you can define as many sub-categories as you need so that you can differentiate between Expenses on different sources.

 

 

Payment reconciliation

The Payment Reconciliation journal now will show you total outstanding transactions and outstanding payments.

From there itself you can now look up the list of documents that have not been applied or used in the reconciliation process.

You can now also choose to include outstanding payments and outstanding transactions information in the Payment Reconciliation report.

 

Jobs

Project Manager Role Center

A new project manager field is added to the Job Card in order to give users clear sense of job ownership.

A new list My Jobs list is added on the Project Manager Role Center which will display jobs with the status of Order by default based on the new project manager field as discussed above.

If a person is assigned as the project manager to 5 jobs and those jobs have the On Order status, those 5 jobs will default on the My Jobs list on the Project Manager Role Center.

A new cue is added to the Project Manager Role Center to Create Job Sales Invoice, so now users will have quick access to this functionality.

On the Project Manager Role Center a new drop down list for Job Reports has been added to the Actions ribbon.

Job cost

A new fact box will be available to the right side of the Job Card to display the job’s cost information.

Now the term Contract is renamed as Billable throughout the Jobs module.

On the Job Card the Allow Schedule/Billable lines and Apply Usage Link options are marked by default for new jobs.

A new report called Job Quote is available so user can send a quote to a customer. This report is available as Word Template so it can be modified using Word and emailed to the contact on the job.

 

Fixed Assets

Now setting up fixed assets is simpler. A standard setup is provided, but allows you to modify it at anytime you want.

You can register fixed asset as cards with complete information, accounting details, and reporting classification.

You can also register purchases of fixed assets through special fixed asset G/L journals where you can also dispose of fixed assets. The right accounting entries are created automatically.

 

Simplified Setup for using Dynamics CRM from inside Dynamics NAV

As you are familiar Dynamics NAV includes opportunity management and basic customer relationship management.

You can easily set up a connection with Dynamics CRM to have more benefit from the strong capabilities that Dynamics CRM offers, such as marketing and customer service capabilities.

A new assisted setup guide to the Business Manager home page will be available that will guide you through the setup process. Once you are through with this setup, you’ll have a seamless coupling of Dynamics CRM records with Dynamics NAV records.

 

 

Simplified opportunity management and CRM functionality

You will find Dynamics NAV CRM module has been simplified and improved in a number of ways:

  1. At place of CRM wizard pages now you will have card pages, so that they can now also run in the Web client with improved user experience.
  2. Worksheet pages also been replaced by list pages so now you can also use the pages in browsers.
  3. The Contact card has been simplified by marking a number of controls as Additional, so that the page default looks simpler.
  4. Mail merge have been replaced with Word reporting. Also, new Word reporting capabilities added to generate email body content based on the related report and the selected report layout.
  5. A new Sales & Relationship Manager Role Center has been added

New wizard has been created that helps users set up email logging (default public folders, rules, and job queue setup).

 

Smart notifications give you advice and recommendations

Similar to one which we discussed in our earlier post for Madeira.

 

Extensions

Microsoft provides the following extensions:

  1. Envestnet Yodlee Bank Feeds
  2. PayPal Payments Standard
  3. QuickBooks Data Migration
  4. Sales and Inventory Forecast

Similar to Madeira few of them we have discussed in our earlier posts, rest will discuss in our upcoming posts.

 

Office 365

If your organization uses Office 365, Dynamics NAV 2017 includes an add-in so you can invoice your customers based on entries in your Outlook calendar.

From the Contacts List in Dynamics NAV, you can manually synchronize your Dynamics NAV contacts to Office 365 People.

The contacts from Office 365 will sync back to Dynamics NAV as well.

There is a filter that can be applied to the synchronization process so users will only need to sync the contacts they use most often. This same filter is used during the automatic background sync as well. This synchronization process also works with Microsoft Outlook on the desktop.

We will discuss in more details in our upcoming posts. This feature is too available in Madeira.

 

 

 

US financial reports

In the US version of Dynamics 2017, added new four financial reports to the Business Manager and Accountant Role Centers:

  1. Balance Sheet
  2. Income Statement
  3. Cash Flow Statement, and
  4. Retained Earnings Statement

These reports use G/L account categories and sub-categories discussed above to group financial data.

 

Source:- https://mbs.microsoft.com/Files/partner/NAV/Readiness_Training/ReadinessTrainingNews/WhatsNewDynamicsNAV2017LimitedBeta.pdf

I will come up with more details in my upcoming posts.

 

 

 

Development Tips, License, Multitenancy, Server

Uploading License to Tenant in Multitenant Environment

When we deploy solution for Multitenant Environment ever Tenant will be required a Separate License. Depending upon the License agreement with Microsoft every Tenant will either share same License or individual License.

Assume we are implementing Distributor Management System. Where every Tenant is a different Business entity linked with the Parent Group.

In this case the Server & Network is provided by the Parent Group and other Business group will share information but they will use their specific License to use the system, doesn’t matter who pays for fee.

In any case we need to upload License to each database in Multitenancy.

Import-NAVServerLicense

Imports a license file into a Microsoft Dynamics NAV database.

Syntax

Parameter Set: __AllParameterSets

Import-NAVServerLicense [-ServerInstance] <String> [-Database <LicenseDatabase> ] [-Force] [-Tenant <TenantId> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: LicenseDataSet

Import-NAVServerLicense [-LicenseData] <Byte[]> [-Force] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: LicenseFileSet

Import-NAVServerLicense [-LicenseFile] <String> [-Force] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

Use the Import-NAVServerLicense cmdlet to import a license file into a Microsoft Dynamics NAV database. If the Microsoft Dynamics NAV Server account specified does not have access to the location where the license file is stored, an error results. Check the Event Log on the Microsoft Dynamics NAV Server computer to see what permissions are required.

After importing a new license, restart all Microsoft Dynamics NAV Server instances to activate the license for client users.

Parameters

-Database<LicenseDatabase>

Specifies the database into which to import the license file. The possible values are described in the following list:

Default = 0

Default; overrides the license file currently in use.

Master = 1

Forces the license file to be global.

NavDatabase = 2

Forces the license file to be local and stored in the Microsoft Dynamics NAV database that is used by the specified Microsoft Dynamics NAV Server instance.

Tenant = 3

Forces the license file to be local and stored in the Microsoft Dynamics NAV database that is used by the tenant that is specified in the Tenant parameter.

Aliases none
Required? false
Position? named
Default Value none
Accept Pipeline Input? false
Accept Wildcard Characters? false

-Force

Forces the command to run without asking for user confirmation.

Aliases none
Required? false
Position? named
Default Value none
Accept Pipeline Input? false
Accept Wildcard Characters? false

-LicenseData<Byte[]>

Specifies the content retrieved from the certificate file by using the Get-Content cmdlet. For more information, see the examples.

Aliases none
Required? true
Position? 2
Default Value none
Accept Pipeline Input? false
Accept Wildcard Characters? false

-LicenseFile<String>

Aliases none
Required? true
Position? 2
Default Value none
Accept Pipeline Input? false
Accept Wildcard Characters? false

-ServerInstance<String>

Specifies the name of a Microsoft Dynamics NAV Server instance. The default instance name is DynamicsNAV80. You can specify either the full name of an instance (such as MicrosoftDynamicsNavServer$myinstance) or the short name (such as myinstance).

Aliases none
Required? true
Position? 1
Default Value none
Accept Pipeline Input? True (ByValue, ByPropertyName)
Accept Wildcard Characters? false

-Tenant<TenantId>

Specifies the ID of the tenant in which you want to import the license, such as Tenant1. This parameter is required unless the specified service instance is not configured to run multiple tenants.

Aliases Id
Required? false
Position? named
Default Value none
Accept Pipeline Input? True (ByPropertyName)
Accept Wildcard Characters? false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required? false
Position? named
Default Value false
Accept Pipeline Input? false
Accept Wildcard Characters? false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required? false
Position? named
Default Value false
Accept Pipeline Input? false
Accept Wildcard Characters? false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.String

You can pipe a string that contains a Microsoft Dynamics NAV Server instance name to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

This cmdlet does not generate any output.

Examples

This example imports a license file that is named “fin.flf” from the current directory into the default database.

C:\PS>Import-NAVServerLicense DynamicsNAV80 -LicenseData ([Byte[]]$(Get-Content -Path “fin.flf” -Encoding Byte))

This example imports a license file that is named “fin.flf” from the current directory into the local Microsoft Dynamics NAV database that is used by the MyInstance Microsoft Dynamics NAV Server instance.

C:\PS>Import-NAVServerLicense MyInstance -LicenseData ([Byte[]]$(Get-Content -Path “fin.flf” -Encoding Byte)) -Database NavDatabase

This example imports a license file that is named “fin.flf” from the current directory into the master database.

C:\PS>Import-NAVServerLicense ‘MicrosoftDynamicsNavServer$MyInstance’ -LicenseData ([Byte[]]$(Get-Content -Path “fin.flf” -Encoding Byte)) -Database Master

This example imports a license file that is named “fin.flf” from the current directory into the database that is used by the specified tenant, Tenant1.

C:\PS>Import-NAVServerLicense ‘MicrosoftDynamicsNavServer$MyInstance’ -LicenseData ([Byte[]]$(Get-Content -Path “fin.flf” -Encoding Byte)) -Database Tenant –Tenant Tenant1

Let import the license to the Tenants which we created in our earlier post.

If you missed previous post you can find it here. Adding Tenants to multitenancy Environment

I have created the Folder and placed my Tenants License in this.

License-1

Set-ExecutionPolicy unrestricted -Force

Import-Module ‘C:\Program Files\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1’

Import-NAVServerLicense MTenantDemo -Tenant ‘Tenant-1’ -LicenseData ([Byte[]]$(Get-Content -Path “C:\User Data\NAV 2015\MultiTenantDemo\Tenant License\Tenant-1.flf” -Encoding Byte))

Import-NAVServerLicense MTenantDemo -Tenant ‘Tenant-2’ -LicenseData ([Byte[]]$(Get-Content -Path “C:\User Data\NAV 2015\MultiTenantDemo\Tenant License\Tenant-2.flf” -Encoding Byte))

Import-NAVServerLicense MTenantDemo -Tenant ‘Tenant-3’ -LicenseData ([Byte[]]$(Get-Content -Path “C:\User Data\NAV 2015\MultiTenantDemo\Tenant License\Tenant-3.flf” -Encoding Byte))

Import-NAVServerLicense MTenantDemo -Tenant ‘Tenant-4’ -LicenseData ([Byte[]]$(Get-Content -Path “C:\User Data\NAV 2015\MultiTenantDemo\Tenant License\Tenant-4.flf” -Encoding Byte))

Import-NAVServerLicense MTenantDemo -Tenant ‘Tenant-5’ -LicenseData ([Byte[]]$(Get-Content -Path “C:\User Data\NAV 2015\MultiTenantDemo\Tenant License\Tenant-5.flf” -Encoding Byte))

Copy the above Script and paste into the Microsoft Dynamics NAV 2015 Administration Shell.

License-2

Our License have now successfully uploaded to respective databases. As the message suggest we need to re-start the service so that new License comes into effect.

You can use above Script to Upload License to individual Tenants, License could be different or same depends how you discussed with Microsoft and purchased.

Development Tips, Multitenancy, Server

Adding Tenants to Multitenancy Environment

In my previous post Creating the Multitenant Environment, We were done with the basic setup for MultiTenantDatabase NAV (8-0) Demo_App, the first Tenant MultiTenantDatabase NAV (8-0) Demo.

All other Tenants can now be created in similar fashion.

It is recommended to create a tenant template, and in turn use this template to make other tenants.

To create a template follow bellow steps:

  • Remove all users leaving only Administrator Account as Super Permission.
  • Remove any Transaction data specific to Company and other Setups
  • Take the backup of the database and keep it as template for other tenant’s database creation. Basically we will restore this database for each new tenant we need to add.

You can restore the database and mount it to the service one by one and rename the company name manually and do other modifications. But if you need to create 100 or 1000 tenants then this process will be quite time taking. To make this step easy we can use CSV file to store all necessary information and create a Shell Script to read information from CSV file and input as parameter to the commands to make this process fast and save with unnecessary effort.

Today I am going to discuss this, as a sample I have taken bare minimum information to get our task done. In real scenario many more things you may require but you can use this as a template and design your CSV and Script accordingly.

Let’s do the Preparation:

AddTenant-1
I have created the Folder structure as shown in above screen shot.

I will keep my CSV File in TenantInfo Folder.

AddTenant-2
I will store my Shell Script in ShellScript Folder.

AddTenant-3

$csv_NAVBuild = Import-Csv “C:\User Data\NAV 2015\MultiTenantDemo\TenantInfo\TenantDetails.csv”

foreach ($line in $csv_NAVBuild)
{
New-NAVDatabase “C:\User Data\NAV 2015\MultiTenantDemo\TenantBackup\TenantBussinessDataBackup.bak” -DatabaseServer $($line.DatabaseServer) -DataFilesDestinationPath “C:\User Data\NAV 2015\MultiTenantDemo\$($line.TenantID).mdf” -LogFilesDestinationPath “C:\User Data\NAV 2015\MultiTenantDemo\$($line.TenantID).ldf” -DatabaseName $($line.TenantID)
Mount-NAVTenant $($line.ServiceName) –Id $($line.TenantID) -DatabaseServer $($line.DatabaseServer) -DatabaseName $($line.TenantID) -OverwriteTenantIdInDatabase -DefaultTimeZone “$($line.DefaultTimeZone)”
Rename-NAVCompany $($line.ServiceName) -Tenant $($line.TenantID) -CompanyName “Tenant-1” -NewCompanyName $($line.TenantID) -Force
}

Save-NAVTenantConfiguration $($line.ServiceName)

I will place my tenant database template file in TenantBackup Folder prepared as per above discussed step. I will take the SQL backup and place the .bak file in this folder.

AddTenant-4
Creating and Mounting Tenants

It is possible to create PowerShell scripts that aids the setup of Tenants. Basically, what the script does, is:

  1. Calls a CSV file (Comma separated file) with settings for all the Tenants
  2. Restores and creates new Tenants based on the tenant template SQL backup
  3. Mounts the new database as a tenant on NAV Server Instance
  4. Renames the default company name to the specified company name
  5. Saves NAV tenant configurations of NAV Server Instance

Open the Microsoft Dynamics NAV 2015 Administrator Shell, Make sure you run it as Administrator. Copy and Paste your above created script.
AddTenant-5
On completion of execution of script, Verify your Tenants are Mounted to the Service using Microsoft Dynamics NAV 2015 Administration.
AddTenant-6
Verify using SQL Server Management your all database is created.

AddTenant-7

Verify that the database Files are created in Specified Folder in the Script.

AddTenant-8

Verify that you are able to login to each Tenant database in RTC.

AddTenant-9

Now you are done with Creating the Tenants and Mounting the same to the Navision Service using CSV file and Shell Script.

Shell Script had made your life so easy, think if manually you have to do it for 5000 tenants how much time will you take to get this task done.

Development Tips, Multitenancy, Security, Server

Creating the Multitenant Environment

Before you start I will recommend to go through my earlier post on Multitenancy Concept & Overview here.

To start with the below steps you will require 2 Accounts preferably Domain Accounts:

  • An Account for running MS Dynamics Navision Service
  • An Administrator account for Database & RTC

How to setup these accounts and what permissions are required for these accounts I would recommend to go through my earlier post on Provisioning the Microsoft Dynamics NAV Server Account here.

Add both the above account to Navision Database with Super permission.

In order to create a multitenant environment (here for Demo Database NAV (8-0)), the following steps need to be done:

  • Take an SQL Backup of the running Demo Database NAV (8-0) database.

Multitenancy-1
Multitenancy-2
Multitenancy-3

  • Restore the newly made SQL Backup to a new database (MultiTenantDatabase NAV (8-0) Demo).

Multitenancy-4
Multitenancy-5
Multitenancy-6
Multitenancy-7

  • On the NAV Server, using the NAV 2015 Administration console, create a new NAV Server Instance named MTenantDemo

Multitenancy-8

  • Edit the instance and set the database to newly created MultiTenantDatabase NAV (8-0) Demo database, and set the instance to be started with NAV Service user.

Multitenancy-9
Multitenancy-10

  • Start MTenantDemo – and see if you can log in
  • Once you have confirmed the MultiTenantDatabase NAV (8-0) Demo database and MTenantDemo is running, split the database in an application part and a data part:
    • Open the NAV 2015 Administration Shell (or Windows PowerShell ISE and load the NavAdminTool)
    • Export the application part from the MultiTenantDatabase NAV (8-0) Demo database to a new database (MultiTenantDatabase NAV (8-0) Demo_App):

Export-NavApplication -DatabaseServer INDEL-AXT5283N1 -DatabaseName ‘MultiTenantDatabase NAV (8-0) Demo’ -DestinationDatabaseName ‘MultiTenantDatabase NAV (8-0) Demo_App’

  • Remove the application part from the MultiTenantDatabase NAV (8-0) Demo database:

Remove-NAVApplication -DatabaseServer INDEL-AXT5283N1 -DatabaseName ‘MultiTenantDatabase NAV (8-0) Demo’

Multitenancy-11
Multitenancy-12

  • Using the NAV 2015 Administration console, edit the MTenantDemo instance and set the database to newly created MultiTenantDatabase NAV (8-0) Demo_App database
    Multitenancy-13
  • And select Multitenant (set it to True):
  • Save and restart MTenantDemo

Multitenancy-14

  • Either through a Powershell commandlet in the NAV 2015 Administration Shell or by using the NAV 2015 Administration console mount a tenant named Tenant-1 on the MTenantDemo NAV Instance:

Multitenancy-15
Multitenancy-16
Multitenancy-17

  • Start NAV using the new tenant:

Multitenancy-18

  • In Companies rename the Company Name to Tenant-1
  • Take an SQL Backup using the MultiTenantDatabase NAV (8-0) Demo_App database, and call it “App_template.bak”
  • Take an SQL Backup using the MultiTenantDatabase NAV (8-0) Demo database, and call it “Tenant_template.bak”

You now have a template you can use when you want to create a application and a tenant.

Restore the Tenant Database as Tenant-2, Tenant-3, Tenant-4, Tenant-5 etc.

Mount the Tenant Databases to NAV Service MTenantDemo as per above steps.

Now you have One Application & 5 Business Data Tenants Mounted.

You will do development in Application Database MultiTenantDatabase NAV (8-0) Demo_App and then Sync your modifications to Business Data Databases named Tenant-1/2/3/4/5 etc.

To Sync your objects to Tenants you will use below script in NAV 2015 Administration Shell:

Set-ExecutionPolicy unrestricted –Force

Import-Module ‘C:\Program Files\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1’

Sync-NAVTenant MTenantDemo -Force -Tenant ‘MultiTenantDatabase NAV (8-0) Demo’

I will explain in more detail on Creating Tenants, Synchronizing Tenants and uploading License for Tenants in more details in my next upcoming post.

Development Tips, Multitenancy, Security, Server

Multitenancy Concept & Overview

You will get step by step walkthrough on how to implement Multitenancy in my next upcoming post.

You can choose to migrate your Microsoft Dynamics NAV solution to a multitenant deployment architecture where you maintain a single application that is used by two or more companies that store their data in separate databases.

This can make maintenance of your solution easier if you support multiple customers with the same application functionality.

Tenants and Companies

When you upgrade your application and the data to Microsoft Dynamics NAV 2015, you have a database that has the same number of companies as you had before the upgrade.

This database is considered a tenant.

This does not mean that you have to turn your solution into a multitenant deployment. But it means that you can if you want to.

For example, your Microsoft Dynamics NAV deployment in the earlier version consisted of a database that has 20 companies.

In other words, you support 20 companies that all share the same application functionality.

Here we are considering, the companies are separate companies that have nothing to do with each other except that they are supported by you in one database.

In Microsoft Dynamics NAV 2015, you can choose to extract the application-wide tables into a separate database and keep the data for all 20 companies in the original database. This becomes a single-tenant business data database.

Then, you can choose to split the business data database into one for each company so that you run a truly multitenant environment.

The application is stored separately in the application database, and you maintain application functionality centrally.

Pros

When you modify the application, you make the changes available to one tenant at a time. As a result, if something goes wrong, all other tenants are not affected.

Compare this to earlier versions of Microsoft Dynamics NAV where a database could contain several companies. These companies could be related or not, but they would all use the same application and write to the same database. Also, when you modified the application, it would affect all companies immediately. So if something went wrong, all companies would be affected.

Cons

The email logging functionality in Microsoft Dynamics NAV requires the Microsoft Dynamics NAV Server service account to have access to the Exchange server. But in a multitenant deployment, this is not always possible.
Separating Application Data from Business Data
Microsoft Dynamics NAV 2015 separates tables that describe the application from the tables that contain business data. Depending on your deployment scenario, you can choose to store all Microsoft Dynamics NAV tables in one database, or you can export the application tables to a dedicated database.

In multitenant deployments, the application must be stored in a dedicated database.
Application Database versus Business Data Databases
The application database contains tables that describe your application.

This includes a description of the objects that your application consists of, and other data that is common to all tenants.

The data that users enter in your application is stored in the business data database because this data is specific to their company.

Optionally, you can create multiple business data databases, such as if you want to support your customers as tenants.

When you have exported the application tables to a separate database, you can no longer access the business database from the Microsoft Dynamics NAV Development Environment. This is because the metadata for the tables in the business database is stored in the application database and modified in that database.

For example, if you want to modify a report, you modify the report object in the application database. Then, when you deploy the updated application to your production environment, when a user accesses the report, they see the modified report.

Microsoft Dynamics NAV includes Windows PowerShell cmdlets that help you export application tables to a dedicated database, and other cmdlets to help you maintain a multitenant deployment.
Distribution of the System Tables in Each Database
The application tables are system tables that define the application. Other system tables remain in the business data database.

The following table describes which system tables are moved to the application database when you run the Export-NAVApplication cmdlet and which tables remain in the business data database.

Application database Business data database
Chart Access Control
Client Add-in Active Session
Client Add-in Resources Company
Debugger Breakpoint Device
Debugger Watch Document Service
Object Integration Page
Object Metadata Object Metadata Snapshot
Object Tracking Object Translation
Permission Page Data Personalization
Permission Set Printer Selection
Profile Record Link
Profile Metadata Report List Translation
Send-To Program Session Event
Server Instance User
Style Sheet User Default Style Sheet
Web Service User Metadata
User Personalization
User Property

Microsoft Dynamics NAV Windows PowerShell Cmdlets
Microsoft Dynamics NAV 2015 includes Windows PowerShell cmdlets for administration and for merging and modifying application object files.

The cmdlets are available in two Windows PowerShell modules: Microsoft Dynamics NAV 2015 Administration Shell and Microsoft Dynamics NAV 2015 Development Shell.

  • The Microsoft Dynamics NAV 2015 Administration Shell includes cmdlets for administering the Microsoft Dynamics NAV deployment, such as adding and configuring Microsoft Dynamics NAV server instances, databases, and users. The Microsoft Dynamics NAV 2015 Administration Shell is installed with the Microsoft Dynamics NAV Server.
  • The Microsoft Dynamics NAV 2015 Development Shell includes cmdlets for merging and modifying application object files. The Microsoft Dynamics NAV 2015 Development Shell is installed with the Microsoft Dynamics NAV Development Environment.

The cmdlets are implemented in Windows PowerShell 3.0, which is included with Windows Server 2012 and Windows 8.

Alternatively to running Microsoft Dynamics NAV 2015 Administration Shell and Microsoft Dynamics NAV 2015 Development Shell from where they are installed, you can import the relevant module into the Windows PowerShell Integrated Scripting Environment (ISE).
Starting a Microsoft Dynamics NAV 2015 Administration Shell Session
You must run the Microsoft Dynamics NAV 2015 Administration Shell as an Administrator. On the computer that is running Microsoft Dynamics NAV Server, choose Start, in the Search box, type Microsoft Dynamics NAV 2015 Administration Shell, right-click the related link, and then choose Run as Administrator.

To run the cmdlets in the Microsoft Dynamics NAV 2015 Administration Shell, you must be a member of the local Administrator group on the computer where the Microsoft Dynamics NAV 2015 Administration Shell is installed.
Starting a Microsoft Dynamics NAV 2015 Development Shell Session
On the computer that is running Microsoft Dynamics NAV Development Environment, choose Start, in the Search box, type Microsoft Dynamics NAV 2015 Development Shell, and then choose the related link.
Creating Tenants from Companies
If your Microsoft Dynamics NAV solution includes multiple companies in one database, you can choose to migrate to multitenancy where the Microsoft Dynamics NAV companies become tenants of your application database.
Companies in Multitenancy Deployments
In Microsoft Dynamics NAV 2015, you can maintain multiple companies in each business database, and you can choose to export all or some of the companies to separate tenant databases.

A tenant database can contain one or more companies. Therefore, you can deploy the number of tenants that suits your solution. This varies between solutions.

You may prefer to have a dedicated tenant database for each legal entity in your deployment. Or you may prefer to have a tenant database for each group of legal entities where each legal entity is a Microsoft Dynamics NAV company in that tenant database.

In this example, we assume that your current deployment consists of one or more databases with multiple companies in each database.

If you migrate your solution as suggested by the examples in this section, you will have a deployment where your application is stored in a dedicated application database.

Each company in the original database will be moved into a dedicated business database, which is mounted as tenants on a Microsoft Dynamics NAV Server instance.

Before you can create tenants from Microsoft Dynamics NAV companies, you must have exported the application to a dedicated application database.

Running a Windows PowerShell Script to Create Tenants from Companies

Microsoft Dynamics NAV includes a sample Windows PowerShell script and a sample SQL script, HowTo-MoveCompanyToTenant.ps1 and HowTo-MoveCompanyToTenant.sql.

These scripts illustrate how you can move company-specific data to new business databases and mount them as new tenants.

You can modify the scripts and then run them in the Microsoft Dynamics NAV 2015 Administration Shell.

Sample Windows PowerShell Scripts for Microsoft Dynamics NAV

The Microsoft Dynamics NAV product media includes a folder that has examples of how you can use the Microsoft Dynamics NAV Windows PowerShell cmdlets to upgrade, deploy, and maintain your Microsoft Dynamics NAV solution.

Microsoft Dynamics NAV Sample Scripts

The sample Windows PowerShell scripts are available in the WindowsPowerShellScripts folder on the Microsoft Dynamics NAV product media.

You can copy the folder to your computer and use the scripts as a starting point for managing your own solution.

Depending on your solution, you can then add the sample Windows PowerShell module into the Microsoft Dynamics NAV 2015 Administration Shell or Microsoft Dynamics NAV 2015 Development Shell and then run the scripts.

The current version of Microsoft Dynamics NAV includes the following sample modules.

Parent folder Module name Description
ApplicationMergeUtilities Contains sample scripts that illustrate different ways of using Windows PowerShell cmdlets to merge and modify application objects. The sample scripts use the Microsoft.Dynamics.Nav.Model.Tools.psd1 module, which you must import first.
Cloud HowTo Contains sample scripts and files for deploying a fully functional end-to-end Microsoft Dynamics NAV solution on Microsoft Azure virtual machines.
NAVAdministration Illustrates how Windows PowerShell can be used to automate the provisioning and management of Microsoft Dynamics NAV installations on a virtual machine (VM).
NAVRemoteAdministration Illustrates how Windows PowerShell can be used to automate the provisioning and management of Microsoft Dynamics NAV installations on Azure VMs.
NAVRemoteAdministrationSamples Provides examples of a fully automated deployment of Microsoft Dynamics NAV on Azure.
Multitenancy NAVMultitenancySamples Illustrates how you can automate the steps that are required to migrate to a multitenant deployment architecture..
Upgrade NAVUpgradeModule Illustrates how you can automate the upgrade of a Microsoft Dynamics NAV 2013 database to Microsoft Dynamics NAV 2015..

Running the Sample Scripts

The sample scripts are designed to be run from the context of the Windows PowerShell module that is part of each collection of sample scripts.

For example, to run the scripts for upgrading to Microsoft Dynamics NAV, import the NAVUpgradeSamples.psm1 module into the Microsoft Dynamics NAV 2015 Administration Shell.

Similarly, to run the sample scripts for merging application objects, open the HowTo-Start-Import-NAV-Module.ps1 script in the Windows PowerShell IDE, navigate the command prompt to the folder where you placed the samples, and then run the script.

The HowTo-MoveCompanyToTenant.ps1 script uses Microsoft Dynamics NAV cmdlets and SQL commands to copy data from a Microsoft Dynamics NAV company in a business database to a new tenant database.

It mounts the tenant database on a Microsoft Dynamics NAV Server instance, and then deletes the data and the company from the original database.

You can adapt the scripts to your solution and rename them so that they do not start with “HowTo-“. Then, you can run the MoveCompanyToTenant.ps1 script in Windows PowerShell with the relevant parameters as shown in the following example.

MoveCompanyToTenant -ServerInstance ‘DynamicsNAV’ -FromDatabase ‘Demo Database NAV (8-0)’ -CompanyName ‘CRONUS International Ltd.’ -OldTenantName default -NewTenantName CRONUS1 -ServiceAccount ‘NT AUTHORITY\NETWORK SERVICE’ -DatabaseServer MySQLServer

In the example, the script will move the CRONUS International Ltd. company from the Demo Database NAV (8-0) database to a new tenant database, CRONUS1.

The script also adds an account for the Microsoft Dynamics NAV Server instance in the new database and removes the company from the original database.

All information that is stored in shared tables, but which is specific to the company, is copied to the new tenant. The following table describes the parameters and the parameter values in the example.

Parameter Value Description
ServerInstance DynamicsNAV The name of the Microsoft Dynamics NAV Server instance.
FromDatabase Demo Database NAV (8-0) The name of the business database that the company must be moved from.

This database must have been upgraded to Microsoft Dynamics NAV 2015, and you must have exported the application tables to an application database..

CompanyName CRONUS International Ltd. The name of the company that you want to move to a new tenant database.
OldTenantName default The name of the tenant in the database that you are exporting from.

In many cases, you are working with a single-tenant business database that contains multiple companies. If you did not specify another ID for the tenant when you created the tenant database, specify default. If you have added more tenants to the solution, you must specify the tenant name.

NewTenantName CRONUS1 The name of the new tenant database.

In the example, this is based on the name of the original company. But because this value will identify the tenant, the value must be unique.

For example, if the name of the company is Spotsmeyer’s Furnishings, the name of the new tenant database can be SPOTSMEYERS. Alternatively, you can use a naming scheme of your choice, such as TENANT1, TENANT2, and so on.

ServiceAccount NT AUTHORITY\NETWORK SERVICE The account that Microsoft Dynamics NAV Server uses to access SQL Server. In a default deployment, this is the NT AUTHORITY\NETWORK SERVICE account.
DatabaseServer MySQLServer The name of the database tier server where the current business database is located. The new tenant database for the exported company will be created on the same server.
RemoveCompanyWhenMoved Specifies if each company must be deleted in the original tenant database when it is created in the new tenant database. The default value is true. Therefore, you must set the parameter to false if you do not want the script to delete the companies.

The script uses the sqlcmd utility to create the database, assign database permissions to the service account, and move the data. This utility is part of SQL Server. The script creates four temporary tables in the original database to handle user-specific data, company-specific data, tables that will not be moved, and user IDs. You must modify the MoveCompanyToTenant.sql script to change the default values.

After this step, you have an application database and a business data database for each company in the original database. The company-specific business data databases are tenants, and your solution is multitenant.

If you want to move back to storing application tables and business data in a single database, you can use the Microsoft Dynamics NAV Windows PowerShell cmdlets to merge the databases.

Merging an Application Database with a Tenant Database

In Microsoft Dynamics NAV 2015, you can separate the application data into a dedicated application database.

However, if you want revert the separation of application data and business data, you can merge the two databases.

Microsoft Dynamics NAV includes Windows PowerShell cmdlets that can help you merge the databases, and you can use the cmdlets in a script that runs in Windows PowerShell.

When you merge the two databases, you migrate to single-tenancy.

In a multitenant deployment, you can merge a single tenant with the application tables and leave the remaining tenants in the existing deployment.

In that case, you add the application tables to the relevant tenant database and leave the original application database unchanged. If you have separated the application data into a dedicated database but you have not used it in a multitenant deployment, you can also use the cmdlet and a sample script to merge the two databases.

Migrating to Single-Tenancy

Before you can start the merge of the two databases, you must collect the relevant information. If you write a script, you must be able to provide values for the parameters that the Windows PowerShell cmdlets require. The migration includes the following main steps:

  • Gather the prerequisite information.
  • Merge the two databases.
    • Migrate from multitenancy to single-tenancy.
    • Migrate from two databases to one database.
  • Change the client connection endpoints.
  • Post-migration clean-up.

Each step is explained in more details in the following sections.

Step 1: Gather the Prerequisite Information

The sample scripts require the following information:

  • Identify the name of the Microsoft Dynamics NAV Server server instance that the tenant database is connected to. This value is used as the input for the serverInstance variable in the sample scripts.
  • Identify the name of the application database that the tenant database is connected to. This value is used as the input for the appDatabaseName variable in the sample scripts.
  • Identify the name of the tenant database that you want to merge with the application database. This value is used as the input for the tenantDatabaseName variable in the sample scripts.
  • If you are migrating from a multitenant deployment, identify the tenant ID of the tenant database. This value is used as the input for the tenantId variable in the sample scripts.
  • Make sure that you have the server role called securityadmin in the relevant instance of SQL Server.
  • Make sure that you have the db_owner role for both the application database and the tenant database.
  • Make sure that you are a member of the Administrators security group on the server that runs the Microsoft Dynamics NAV Server instance and where the Windows PowerShell scripts run.

Step 2: Merge the Two Databases

To merge the application database and the tenant database, you must run the Microsoft Dynamics NAV 2015 Administration Shell as an administrator.

Depending on your scenario, you can copy one of the sample scripts and update the variables based on the prerequisite information that you gathered in the previous section.

This section includes two sample scripts that you can base your own script on.

The first script merges an application database and a tenant database that is currently a tenant in a multitenant deployment.

# PURPOSE: This sample script migrates a tenant in a multitenant deployment to a single-tenant deployment.

### Modify these variables with values appropriate to your environment ###

$serverInstance = “”

$appDatabaseName = “”

$tenantDatabaseName = “”

$tenantId = “”

### You should not need to modify any variables below this line ###

# Save the current multitenancy configuration.

Save-NAVTenantConfiguration -ServerInstance $serverInstance

# Create a new server instance for the requested tenant.

New-NAVServerInstance -ServerInstance $tenantId -ManagementServicesPort 7045

# Dismount the requested tenant from the multitenant server instance.

Dismount-NAVTenant -ServerInstance $serverInstance -Tenant $tenantId

# Save the updated multitenancy configuration.

Save-NAVTenantConfiguration -ServerInstance $serverInstance

# Remove any application tables from the tenant database if these were not already removed.

Remove-NAVApplication -DatabaseName $tenantDatabaseName

# Copy the application tables from the current application database to the tenant database.

Export-NAVApplication -DatabaseName $appDatabaseName -ApplicationDatabaseName $tenantDatabaseName

# Reconfigure the CustomSettings.config file for the new server instance to use the tenant database.

Set-NAVServerConfiguration -ServerInstance $tenantId -KeyName DatabaseName -KeyValue $tenantDatabaseName -WarningAction Ignore

# Reconfigure the CustomSettings.config to use single-tenant mode.

# Set-NAVServerConfiguration -ServerInstance $serverInstance -KeyName Multitenant -KeyValue false -WarningAction Ignore

# Start the new server instance if it is not running.

Set-NAVServerInstance -ServerInstance $tenantId -Start

# Dismount all tenants on the new server instance that are not using the current tenant database.

Get-NAVTenant -ServerInstance $tenantId | where {$_.Database -ne $tenantDatabaseName} | foreach { Dismount-NAVTenant -ServerInstance $tenantId -Tenant $_.Id }

# Save the new single-tenant configuration.

Save-NAVTenantConfiguration -ServerInstance $tenantId

Write-Host “Operation complete.” -foregroundcolor cyan

The second script merges an application database and a tenant database that has not been mounted on a Microsoft Dynamics NAV Server instance as a tenant.

# PURPOSE: This sample script merges an application database and a tenant database that are not part of a multitenant deployment.

### Modify these variables with values appropriate to your environment ###

$serverInstance = “”

$appDatabaseName = “”

$tenantDatabaseName = “”

### You should not need to modify any variables below this line ###

# Save the current server configuration.

Save-NAVTenantConfiguration -ServerInstance $serverInstance

# Stop the server instance if it is running.

Set-NAVServerInstance -ServerInstance $serverInstance -Stop

# Remove any application tables from the tenant database if these have not already been removed.

Remove-NAVApplication -DatabaseName $tenantDatabaseName

# Copy the application tables from the application database to the tenant database.

Export-NAVApplication -DatabaseName $appDatabaseName -ApplicationDatabaseName $tenantDatabaseName

# Reconfigure the CustomSettings.config to use the tenant database.

Set-NAVServerConfiguration -ServerInstance $serverInstance -KeyName DatabaseName -KeyValue $tenantDatabaseName -WarningAction Ignore

# Reconfigure the CustomSettings.config to use single-tenant mode

# Set-NAVServerConfiguration -ServerInstance $serverInstance -KeyName Multitenant -KeyValue false -WarningAction Ignore

# Start the server instance.

Set-NAVServerInstance -ServerInstance $serverInstance -Start

# Dismount all tenants that are not using the current tenant database.

Get-NAVTenant -ServerInstance $serverInstance | where {$_.Database -ne $tenantDatabaseName} | foreach { Dismount-NAVTenant -ServerInstance $serverInstance -Tenant $_.Id }

# Save the current single-tenant configuration.

Save-NAVTenantConfiguration -ServerInstance $serverInstance

Write-Host “Operation complete.” -foregroundcolor cyan

In both scenarios, you can create scripts that are based on these samples, provide value for the variables, run the script, and the review the output to make sure that you achieved the expected result.

Step 3: Change the Client Connection Endpoints

The first sample script creates a new Microsoft Dynamics NAV Server instance with a name that is based on the specified tenant ID.

The script only enables the management services endpoint in the Microsoft Dynamics NAV Server configuration settings.

You must also configure the server instance to enable client services, SOAP web services, and OData web services.

You must send the configuration changes to the users who access the reconfigured tenant. Otherwise, they are not able to connect to the database.

The second sample script illustrates a simpler scenario where you move the application tables to the only database that accessed the application database. As a result, all client endpoints continue as they did before, and you do not have to update any clients.

Step 4: Post-Migration Clean-Up

In the first scenario where you move a tenant from multitenancy to single-tenancy, you must update the Microsoft Dynamics NAV Server account and database permissions.

Also, any tenant-specific files that have been saved to the original server location must be moved to the relevant location on the new server.

You will get step by step walkthrough on how to implement Multitenancy in my next upcoming post.