Microsoft Dynamics NAV

Team Blog

  • Microsoft Dynamics NAV Team Blog

    Coffee Break - Automatic Deployment of Microsoft Dynamics NAV

    • 3 Comments

    This post will round up a small series of how to use Windows PowerShell to provision Dynamics NAV in an automated way. In our examples we do this in the cloud, since here we can already automate the machine and OS deployments, but the techniques here will work in any environment. The key element here is "Automation".

    Coffee Break 12 - Provisioning - Automatic installation and deployment of Microsoft Dynamics NAV

    Previously we looked at how to use PowerShell to:

    1. Create a Virtual HardDisk (VHD),
    2. Create a Virtual Machine (VM) in the cloud, then
    3. Upload our new VHD to our new VM.

    Now, finally we will show how to go ahead an install Dynamics NAV on this new machine. 

    Why provision?

    There is actually a much easier way to get Dynamics NAV running in the cloud: Use the pre-built Dynamics NAV image in Microsoft Azure. If your Azure subscription is an MSDN subscription, then the Azure marketplace should show a Dynamics category when you create a new VM. This category contains a Dynamics NAV image with a complete, pre-configured Dynamics NAV installation. This image can of course also be provisioned using PowerShell. Here's a command that looks for pre-built Dynamics NAV images in the Azure marketplace:

    Add-AzureAccount
    Get-AzureVMImage | where { $_.ImageFamily -ilike “*NAV*” } | Sort-Object -Descending -Property PublishedDate

    But as mentioned above, the key word here is "Automation". So if a ready-built system is not flexible enough, then keep reading.

    Prerequisites

    In this post we will assume that you have already created a new VM and uploaded a Dynamics NAV product DVD to this machine.

    Disclaimer

    The nature of flexibility is that you will need and want to customize this to your exact situation. So the script below will likely need changes, but hopefully it will demonstrate well enough how to complete your automated deployment. The script below is based on the provisioning script on the Dynamics NAV 2013 R2 / Dynamics NAV 2015 product DVD (the folder WindowsPowerShellScripts\Cloud).

    Get started with some settings and load the NAVRemoteAdmin module:

    Add-AzureAccount

    $DVDLocationLocal = "C:\NAVDVD"

    $DVDLocationRemote = "C:\NAVDVD"

    Import-Module $DVDLocationRemote\WindowsPowerShellScripts\Cloud\NAVRemoteAdministration\NAVRemoteAdministration.psm1 

    Before we continue take a few moments to run this and see the cmdlets that you now have available from the NAVRemoteAdmin module:

    Get-Command -Module NAVRemoteAdministration

    Some of these commands are really useful for bridging the gap between your laptop and the cloud and this post will show how much this module helps simplifying remote tasks.

    Now we move on and set a few more variables, and then create a PSSession object to access the remote machine.

    # Specify the location of your Azure VM

    $RemoteMachineAddress = "navnew.cloudapp.net"
    $RemoteMachine = "navnew"

    $PSSession = New-NAVAdminSession -RemoteMachineAddress $RemoteMachineAddress -AzureServiceName $RemoteMachine -VMAdminUserName vmadmin -VMAdminPassword HelloWorld2

     

    Configure an installation config file by running Setup from the product DVD, and then in the installation wizard select to save configuration.xml. Here, we have configured and saved an installation config file in 1BoxConfigFile.Xml, overwriting the existing demo file:

    # Copy installation config file from local machine to the Azure VM

    Copy-FileToRemoteMachine -SourceFile $DVDLocationLocal\WindowsPowerShellScripts\Cloud\NAVRemoteAdministrationSamples\1BoxConfigFile.Xml -DestinationFile $DVDLocationRemote\1BoxConfigFile.xml -Session $PSSession

     

    In case we need a certificate for Web Client connection:

    # Generate a self-signed certificate
    $Certificate = Install-SelfSignedCertificateRemotely -SubjectName $RemoteMachineAddress -StoreScope 'LocalMachine' -StoreName 'My' -RemoteDirectory "c:\Cert" -Session $PSSession

     

    # Or import a signed certificate
    # [System.Security.SecureString]$CertificatePfxPasswordAsSecureString = ConvertTo-SecureString $CertificatePfxPassword -AsPlainText -Force

    #########

    $WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotely
    $WebServerSSLCertificateThumbprint = Get-CertificateThumbprint -Certificate $Certificate
    $Certificate = Import-PfxFileRemotely `
                                    -PfxFile $CertificatePfxFilePath `
                                    -PfxPassword $CertificatePfxPasswordAsSecureString `
                                    -Session $MySession                               
    #################


    # Get installed certificate thumbprint
           
    $WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotely -Certificate $Certificate -Session $PSSession

     

    Install the .NET Framework if needed

    Ideally, make sure that the VM you provisioned already has the required version of .NET Framework (4.5). Or if needed you can automate it - look in the provisioning script on the Dynamics NAV 2015 product DVD in WindowsPowerShellScripts\Cloud\NAVRemoteAdministrationSamples\Install-DotNETRemotely.ps1 how to install it and restart the VM remotely if needed.

     

    Install Dynamics NAV

    # Install prerequisites on VM      
    $DVDLocationRemote = "C:\NAVDVD"
    Install-NAVPrerequisitesRemotely -RemoteNavDvdLocation $RemoteNavDvdLocation -Session $PSSession | Out-Null

    # Install NAV components from dvd copied to VM
    Install-NAVComponentRemotely –RemoteDVDPath $DVDLocationRemote RemoteConfigurationFilePath $DVDLocationRemote\1BoxConfigFile.xml –Session $PSSession

     

    Additional (optional) settings and finishing off

    # Remove the default IIS web site to free port 80 for the NAV Web Client
    Remove-DefaultWebSiteRemotely -Session $PSSession  

    #Start the web site   
    Start-NAVWebClientRemotely -Session $PSSession

    #Open Azure endpoint for the Web Client. We assume the web client will always occupy port 443.
    $RemoteMachine = "navnew"
    $RemoteServiceName = "navnew"
    Get-AzureVM -Name $RemoteMachine -ServiceName $RemoteServiceName | Add-AzureEndpoint -Name "NAV_Web_Client" -Protocol "tcp" -LocalPort 443 -PublicPort 443 | Update-AzureVM | Out-Null

     

    This was an example of how to install Dynamics NAV on one machine. Watch out for future posts on how to automate deployment on multiple machines. Example scenario: Automating Cumulative Update deployment.

     

     

    Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

    Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

    Bas Graaf, Senior Software Engineer Dynamics NAV

     

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 26 for Microsoft Dynamics NAV 2013 has been released

    • 0 Comments

    Cumulative Update 26 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013.

    The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions: 

    • AU - Australia
    • AT - Austria
    • BE - Belgium
    • CH - Switzerland
    • DE - Germany
    • DK - Denmark
    • ES - Spain
    • FI - Finland
    • FR - France
    • IS - Iceland
    • IT - Italy
    • NA - North America
    • NL - Netherlands
    • NO - Norway
    • NZ - New Zealand
    • SE - Sweden
    • UK - United Kingdom

    Where to find Cumulative Update 26

    You can download the cumulative update from KB 3058009 - Cumulative Update 26 for Microsoft Dynamics NAV 2013 (Build 40940).

    Additional Information

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013

    For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

    CustomerSource:

    PartnerSource:

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 19 for Microsoft Dynamics NAV 2013 R2 has been released

    • 0 Comments

    Cumulative Update 19 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013 R2.

     The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    •   AU - Australia
    •   AT - Austria
    •   BE - Belgium
    •   CH – Switzerland
    •   CZ – Czech Republic
    •   DE - Germany
    •   DK - Denmark
    •   ES - Spain
    •   FI  - Finland
    •   FR - France
    •   IS - Iceland
    •   IT - Italy
    •   NA - North America
    •   NL - Netherlands
    •   NO - Norway
    •   NZ - New Zealand
    •   RU – Russia
    •   SE - Sweden
    •   UK - United Kingdom

    Where to find Cumulative Update 19

    You can download the cumulative update from KB 3058010  – Cumulative Update 19 for Microsoft Dynamics NAV 2013 R2 (Build 40941). 

    Additional Information

    For more information about cumulative updates for this version, see Announcement of update rollups for Microsoft Dynamics NAV 2013 R2.

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013 R2

    For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

    CustomerSource:

    PartnerSource

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 7 for Microsoft Dynamics NAV 2015 has been released

    • 0 Comments

    Cumulative Update 7 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2015. 

     The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    •   AU - Australia
    •   AT - Austria
    •   BE - Belgium
    •   CH – Switzerland
    •   CZ – Czech Republic
    •   DE - Germany
    •   DK - Denmark
    •   ES - Spain
    •   FI  - Finland
    •   FR - France
    •   IS - Iceland
    •   IT - Italy
    •   NA - North America
    •   NL - Netherlands
    •   NO - Norway
    •   NZ - New Zealand
    •   RU – Russia
    •   SE - Sweden
    •   UK - United Kingdom

    Note: You must convert the database if you are upgrading to this cumulative update from a cumulative update earlier than Cumulative Update 4 (build 39663). For more information, see Converting a Database in Help for Microsoft Dynamics NAV. 

    Where to find Cumulative Update 7

    You can download the cumulative update from KB 3058000 – Cumulative Update 7 for Microsoft Dynamics NAV 2015 (Build 40938). 

    Additional Information

    For information about how to install the cumulative update, see How to Install a Microsoft Dynamics NAV 2015 Cumulative Update

    For information about how to work around a recent process change, see How to Get Back the 'Hotfix Directories' from NAV 2015 Cumulative Update 1.

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2015.  

  • Microsoft Dynamics NAV Team Blog

    Coffee Break – keeping stuff in the cloud

    • 13 Comments

    In the last few Coffee Break posts we have been looking at virtual hard disks (VHDs) and virtual machines (VMs). Now let's combine the two in the cloud.

    Coffee Break 11 – Provisioning - Using Microsoft Azure storage to keep VHDs and other useful stuff in the cloud

    Provisioning a new instance of Microsoft Dynamics NAV is like putting individual bits together. In this Coffee Break post, we will prepare some of these bits by building a VHD up front and then upload it to Azure. Then every new virtual machine (VM) can pick a copy of this disk. A VHD like this can contain anything such as the Microsoft Dynamics NAV product DVD, application objects, add-on databases, documents, and so on. And we can save a bit of time and bandwidth compared to uploading a new DVD, for example, every time we provision a new VM in the cloud.

    Customer Story:

    The customer is frequently creating new VMs. And every new VM they create will need access to common data, such as the Microsoft Dynamics NAV product DVD.

    Prerequisites:

    1 VHD (local) and 1 VM (In Azure):

    Create a VHD: Coffee Break - Windows PowerShell and creating a Hyper-V disk

    Create a VM: Coffee Break – Using Windows PowerShell to provision virtual machines

    Get the VHD to the VM

    Once we have a VHD (locally) and a VM in Azure (whether this was created manually or via PowerShell), let's combine the two. First, upload the VHD to Azure. Connect your ISE PowerShell environment to your Azure subscription:
    Add-AzureAccount

    Create a new storage account to hold our VHD:

    $SourceStorageAccount = "mysharedstuff"

    First test that the storage name is actually available:

    Test-AzureName -Storage $SourceStorageAccount

    If it is (the line above returns False), then create it:

    New-AzureStorageAccount -StorageAccountName $SourceStorageAccount -Location "West Europe"

     

    Optionally we can add containers to this storage, just to keep things organized. First, let's create a context that includes access information for our new storage:

    $Key = (Get-AzureStorageKey -StorageAccountName $SourceStorageAccount).Primary
    $Context = New-AzureStorageContext -StorageAccountName $SourceStorageAccount -StorageAccountKey $Key

    This $Context variable gives us access to the storage, and is one we will use a couple of times.

    Create a container in our storage to store vhds:

    New-AzureStorageContainer -Context $Context -Name vhds

    Upload the VHD

    Let’s say you have a local VHD here: C:\temp\mydisctest.vhd. Then copy that up to your storage:
    Add-Azurevhd -LocalFilePath C:\temp\mydisctest.vhd -Destination "https://$SourceStorageAccount.blob.core.windows.net/vhds/mydisk.vhd"

    If you get this error: "The process cannot access the file 'C:\temp\mydisctest.vhd' because it is being used by another process." then make sure that the disk is not already mounted to your local machine. Note that if you happen to double-click on the VHD, Windows may automatically mount it. You can dismount it like this:

    Dismount-VHD -Path C:\temp\mydisctest.vhd

    (side note:) If you should ever need to copy it back, use  Save-AzureVhd.

    The Add-Azurevhd cmdlet does a clever copy by checking that this is a valid VHD, and by copying only actual data. So if the disk itself is 3GB but is only 5% full, then only a file the size of the 5% will actually be copied.

    Make a copy

    Every time we want a new disk, then we can make a new copy of this VHD, rather than attaching it directly in which case we could only use it for one VM. First create a new container for our copy. This container could relate somehow to the VM that we will be attaching the VHD to:

    New-AzureStorageContainer -Context $Context -Name myvm

    Then copy mydisk.vdh from vhds to myvm:

    $SourceURI = "https://$SourceStorageAccount.blob.core.windows.net/vhds/mydisk.vhd"

    $State = Start-AzureStorageBlobCopy -AbsoluteUri $SourceURI -DestContainer myvm -DestBlob NewVHD.vhd -Context $Context

     

    This will start an asynchronous copy. To check status before using the copy:

    $state | Get-AzureStorageBlobCopyState

     

    Get it together

    Now we have a fresh copy of the VHD in Azure, let’s attach it to a VM, using the cmdlet Add-AzureDataDisk. The two main ways we can use this cmdlet are:

    • ImportFrom – to import an existing VHD - the one we will use here
    • CreateNew – to create a new raw disk

    The syntax of the cmdlet is:
    $vm | Add-AzureDataDisk | Update-AzureVM


    So, we need to get the VM, then pipe it through in that way. First check that you have the right VM. See which ones you have available:

    Get-AzureVM
    Then pick one:
    $VM = get-azurevm -ServiceName mytestserviceabcdef -Name NAVPC

    Check that you still have the location for your VHD and then store that in another new variable:
    $NewVHD = "https://$SourceStorageAccount.blob.core.windows.net/myvm/NewVHD.vhd"

    Then put $VM through the pipe (or edit the line above if you want to have it all in just one line):
    $VM | Add-AzureDataDisk -ImportFrom -DiskLabel "MyStuff" -MediaLocation $NewVHD -LUN  3 | Update-AzureVM

    If you want to watch as it is happening, connect (RDC) to one of your Azure VMs and run File Explorer. Leave that in the background – it will update automatically and you can see when the disk is added. The disk is ready to use, and the files you put on it back when the disk was still on your local machine, are available now in your VM.

    To remove it again, run this:

    $VM | Remove-AzureDataDisk -LUN 3 -DeleteVHD | Update-AzureVM

    Check what disks (if any) are still attached:

    $VM | Get-AzureDataDisk

     

    Note:

    If you attach and then detach the disk, Azure may still hold a lease on this disk, and it may not be free to use yet or even to be deleted. This is the error you may get when trying to attach the disk again or delete it: "The MyDisk VHD is already registered with image repository as the resource with ID XYZ". In this case we may not be able to delete the disk automatically, which is why in the example above, if we remove the disk, then delete the disk as part of that operation.

    So, just to avoid problems like this: When we detach a disk, then just to keep things clean, use -DeleteVHD to remove the disk completely.

     

     

    Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

    Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

    Bas Graaf, Senior Software Engineer Dynamics NAV

     

  • Microsoft Dynamics NAV Team Blog

    Coffee Break – Using Windows PowerShell to provision virtual machines

    • 0 Comments

    The  previous coffee break was about creating a new Virtual Hard Disk (vhd). This time we will create the rest of the machine (VM) in Microsoft Azure.

    Coffee Break 10 – Provisioning (Creating a Virtual Machine (VM) in Azure)

    A central part of provisioning a Microsoft Dynamics NAV deployment is of course to provision the actual machine (well the virtual actual one) that the system is running on. The provisioning script on the Microsoft Dynamics NAV product media has two options – both in the “WindowsPowerShellScripts\Cloud\HowTo” folder:

    • Example-1VM.ps1 – Provision one VM that runs both SQL Server and Microsoft Dynamics NAV
    • Example-2VM.ps1 – Provision two machines, one for SQL Server and one for Microsoft Dynamics NAV

    In this post we will keep it simple and just provision one machine. In later posts we will see how to install Microsoft Dynamics NAV on it. This post assumes that you have an Azure account. If you don’t then you can request a free trial here http://azure.microsoft.com/en-gb/pricing/free-trial/ .

    Choose an image

    In the Azure Management Portal (https://manage.windowsazure.com ), go to New -> Compute -> Virtual Machine -> From Gallery, then pick one, and follow the rest of the steps to create a new VM.

    To do this with Windows PowerShell, first connect your PowerShell prompt to your Azure subscription:

    Add-AzureAccount

    Use Get-AzureVMImage to get a list of available images:

    Get-AzureVMImageselect ImageFamily | Group-Object ImageFamily | Format-Table -AutoSize

     Browse through that list and choose any image you like. For this example let’s pick one that already has SQL Server installed:

    $imageFamily = "SQL Server 2014 RTM Standard on Windows Server 2012 R2"

    The image library on Azure is very much alive and keeps changing as machines get updated. This will choose the latest version of the image family you chose:

    $imageName = Get-AzureVMImage | where { $_.ImageFamily -eq $imageFamily } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1

     

    The VM you make will live in a Service. The Service name must be unique world-wide. So pick a Service name:

    $ServiceName = "mytestserviceabcdef"

    Test-AzureName -Service $ServiceName 

    Test-AzureName returns True if someone somewhere in the world already picked the name you specified. You must update ServiceName until Test-AzureName returns False.

    Next, decide on the name of your VM. This only has to be unique for yourself:

    $Name = "NAVPC"

     

    Then we are ready for the main event!

    Creating a new VM

    In Windows PowerShell: 

    New-AzureQuickVM -ImageName $imageName -ServiceName $ServiceName -Name $Name -Windows -Location "West Europe" -AdminUsername vmadmin -Password "HelloWorld2" -WaitForBoot

    Notice the last parameter here –WaitForBoot. New-AzureQuickVM will provision and boot a new VM. If we specify –WaitForBoot, then the command will not complete until the new VM is booted (or failed), which can take 5-10-15 minutes or more or less. If you want the command to return sooner, then run it without this parameter. In that case, go to “Virtual Machines” in your Azure portal, and refresh to see status of your new VM while it is provisioning. Or watch status from PowerShell:

    Get-AzureVM -ServiceName $ServiceName -Name $Name

    Or to have a loop that checks and updates every 5 seconds, look in the provisioning tool in NAVRemoteAdministration\Azure\Wait-VMReadyState.ps1. With this method, if a user is waiting for the script to finish then at least they know that it is processing.

    If the script fails the first (few) times, then second time you run it you may get error that Service already exists. In this case, go to “Cloud Services” in your Azure portal, and clean up (delete the service that was created). Or do it via PowerShell:

    Remove-AzureService $ServiceName

     

    After this, you should have your new VM ready and you can connect to it from the Azure portal. Or if you find it hard to leave your favourite environment (ISE), connect to your new machine directly from PowerShell:

    Get-AzureRemoteDesktopFile -ServiceName $ServiceName -Name $Name -LocalPath c:\Temp\remote.rdp

    c:\Temp\remote.rdp

      

     

    Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

    Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

    Bas Graaf, Senior Software Engineer Dynamics NAV

     

  • Microsoft Dynamics NAV Team Blog

    Watch Out for Zombies When Using Microsoft Dynamics NAV with “xact abort” Enabled

    • 2 Comments

    If you have turned on the xact abort connection setting option for the Microsoft Dynamics NAV SQL Server instance, then you should watch out for Zombies. With this option turned on, users of your solution risk seeing an error stating This SqlTransaction has completed; it is no longer usable along with a crash signature which includes a call to the ZombieCheck() function.

    You can set the xact abort configuration option on a SQL Server instance by right clicking on the instance name in SQL Server Management Studio and then selecting Properties. Select the Connections page, and then, in the Default Connection Options list as shown in the screenshot below, you will see the xact abort option at the end of the list: 

    If you enable xact abort as a default connection option in SQL Server, the SQL Server engine will automatically roll back the current transaction entirely if a Transact-SQL statement executed by the relevant SQL connection raises a run-time error. If this option is turned off then some SQL Server errors may not force a complete rollback (depending on the severity of the error). The above setting defines the default for all connections, but this default can be overridden at connection time on a per-connection basis if the application developer has included code to explicitly set this option one way or the other.

    For Microsoft Dynamics NAV 2013 R2 and Microsoft Dynamics NAV 2015, we do not specify any setting for “xact abort” when a connection to SQL Server is being established and therefore pick up whatever default specified at the SQL Server instance level (as shown above). Most of the time this is fine, but in some circumstances we have reports that the  Microsoft Dynamics NAV client may crash with the error message This SqlTransaction has completed; it is no longer usable. If you check in the Windows Event Log on the  Microsoft Dynamics NAV middle-tier machine you will see the following message and stacktrace posted by Microsoft Dynamics NAV Server:

    Type: System.InvalidOperationException

    Message: This SqlTransaction has completed; it is no longer usable.

    StackTrace:

         at System.Data.SqlClient.SqlTransaction.ZombieCheck()

         at System.Data.SqlClient.SqlTransaction.Commit()

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteAction(Action action, NavSqlCommand command, Boolean isRollbackAction)

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteActionWithTrace(EventTask task, String tenantId, Int32 sessionId, String userName, Action action, NavSqlCommand command)

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.EndTransaction(NavSqlEndTransactionType endType)

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.CheckBeginTransaction(TransactionType transactionType)

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnectionScope..ctor(NavDatabase database, Boolean requireNewConnection, TransactionType transactionType, NavSqlConnection lastUsedSqlConnection)

         at Microsoft.Dynamics.Nav.Runtime.NavSqlConnectionScope.Create(NavDatabase database, TransactionType transactionType, IReference`1& lastUsedSqlConnection)

         at Microsoft.Dynamics.Nav.Runtime.SqlTableDataProvider.BeginTransaction(TransactionType transactionType)

         at Microsoft.Dynamics.Nav.Runtime.TransactionManager.EnsureReadTransactionStarted()

         at Microsoft.Dynamics.Nav.Runtime.TransactionalDataCache.TryGetExists(ExistsCacheRequest request, Boolean& exists, DataLockState& lockState, Int32& transactionBumperToken, Action`1& updateCache)

         at Microsoft.Dynamics.Nav.Runtime.DataAccess.Exists(ExistsCacheRequest request)

         at Microsoft.Dynamics.Nav.Runtime.RecordImplementation.ValidateNonFlowField(NCLMetaField field, Boolean isUserInput)

         at Microsoft.Dynamics.Nav.Runtime.NavRecord.ValidateField(Action`1 fieldEvent, NCLMetaField metaField, Boolean isUserInput)

         at Microsoft.Dynamics.Nav.Runtime.NavRecord.Validate(NCLMetaField metaField, NavValue newValue, NavRecord callerRecord, Boolean isUserInput)

         at Microsoft.Dynamics.Nav.Runtime.NavRecord.ValidateFields(IEnumerable`1 fieldNumbers, NavRecord callerRecord)

         at Microsoft.Dynamics.Nav.Runtime.NavForm.NewRecord(Boolean belowXRec)

    Source: System.Data

    HResult: -2146233079

     

    The scenarios where the above error can happen vary somewhat but the factor they have in common is that the xact abort connection setting is enabled for the relevant SQL Server instance. In future versions of Microsoft Dynamics NAV, we will add code to explicitly disable xact abort for all  Microsoft Dynamics NAV sessions at connection time. However, for Microsoft Dynamics NAV 2013 R2 and Microsoft Dynamics NAV 2015, it is advisable to turn off the xact abort option at the SQL instance level if none of the other databases on the same SQL Server instance require it.

    If other application databases on the same SQLServer instance require that the default connection option for xact abort is turned on, and you encounter the above issue with Microsoft Dynamics NAV, then you could consider moving the Microsoft Dynamics NAV database to another instance of SQL Server.

     

    Gerard Conroy

    Microsoft Dynamics NAV Support EMEA

  • Microsoft Dynamics NAV Team Blog

    Coffee Break - Windows PowerShell and creating a Hyper-V disk

    • 4 Comments

    After covering some basic management operations for Microsoft Dynamics NAV, we thought it might be the time to look under the hood of the Dynamics NAV cloud provisioning script. The script in its entirety is fairly large and complex. But stripped away from all the wrappings and bundling, it can be broken down to small, fairly simple units.

    Coffee Break 9 - Provisioning (Creating Hyper-V disks)

    Provisioning is the PowerShell scripts on the Dynamics NAV product DVD in the folder WindowsPowerShellScripts\Cloud\. It's a set of scripts that are designed to take the parameters you specify, then provide a whole new Dynamics NAV machine (or two) in Microsoft Azure, with Dynamics NAV running on it/them. In short, the script creates a vhd with NAV DVD and a database copied from locations you provide through parameters. Next, that VHD is uploaded to Azure Storage (also specified through parameters). Then, a VM with SQL image you chose is created and the VHD is mounted on to that VM, the contents of VHD (NAVDVD and database) are copied to the VM and finally the script deploys NAV on the VM.

    You might ask yourself why, given that today you only need to provide a few parameters to run the script, would you want to break it up into bits? Well, first of all, it will give clarity of what happens when provisioning and why, which makes this process a bit less of a black box. That again can help troubleshooting the script (should you run into any issues on your environment), tailor the script to your needs (it is, after all, made for one standard scenario), give you the chance to select and use the parts of the script that you might find useful for your daily management on your Dynamics NAV solution, whether physical or virtual environments, on-premises, or in the cloud.


    The entire script consists of quite a few cmdlets and we have tried to break it up and group it into smaller logical units that we will present over several coming posts.


    So get your coffee mugs filled up and let’s start.

    The first part of the provisioning script creates a VHD with a Dynamics NAV DVD, and uploads that to your azure storage (also created, if the one with the name provided in parameters list doesn’t already exist).
    To create a VHD, we simply invoke diskpart.exe. This utility is used to enable storage configuration from a script, a remote session, or another command prompt. Diskpart enhances the Disk Administrator graphical user interface (GUI).

    For more details of how it is used in our cmdlets, see scripts provided in following path: NAVDVD\WindowsPowerShellScripts\Cloud\NAVAdministration\Windows\Vhd”.
    However, to make it a bit more interesting and give you an alternative in your every-day operations, we thought that we could provide you with an alternative for this part of the process, using another utility: Hyper-V management module. PowerShell module for Hyper-V management is available on Windows 2008 and 2012 servers, by simply adding a hyper-v role to your server. All you need to do to use it (after adding the Hyper-V role) is remember to run your PowerShell console As Administrator, and enable execution policy (RemoteSigned or Unrestricted).

     

    To create a VHD, we’ll perform the following steps: 

    1.  Create the disk.

    For this New-VHD commandlet is used (part of Hyper-V powershell module). Provide the path to the disk, disk size provided in GBs (calculate the size with what you plan on placing on your disk in mind: NAV DVD/ customer backup database/template database/ your solution/third-party tools, ….) and disk type.
    Make sure it's VHD and not VHDX (if you have a VHDX, convert it with the Convert-VHD Windows PowerShell cmdlet) and make sure the size is 1023GB or less (keep in mind the upload time and network bandwith).  The VHD does not have to be fixed type but will be converted to fixed type by the Add-AzureVhd PowerShell cmdlet when it's copied into Azure, so might as well be created as fixed.
    New-VHD –path “c:\temp\mydisc.vhd” –sizebytes 3gb –fixed

    This should take a few seconds for a disk of 3 gbs to complete. Once complete, mount your new vhd:

    Mount-VHD –path “c:\temp\mydisc.vhd”

    To see the properties of this new disk, including disk number:

    Get-VHD “c:\temp\mydisc.vhd”

     

    2.  Initialize the disk.

    Use the Initialize-Disk commandlet to initialize the raw disk, specify MBR Partition Style.


    To initialize the disk you need the disknumber returned by running Get-VHD (see step 1). Then use Initialize-disk cmdlet and specify partition style MBR.
    Initialize-Disk -Number 3 -PartitionStyle MBR
    Your disk is now initialized.

     

    3.  Partition the disk.

    Use the New-Partition function, choose a drive letter, or let OS assign a new drive letter to the drive, or assign one yourself using –DriveLetter parameter. Specify the largest partition size that the disk will support (max size here):
    New-Partition –DiskNumber 3 -AssignDriveLetter -UseMaximumSize
    Or specify the drive letter:
    New-Partition –DiskNumber 3 -DriveLetter “M” –UseMaximumSize
    Once this has run, you will be automatically prompted with following:
     


    You can select format disk here, but as we want a complete PS scenario, we will also do this bit using cmdlet, so select cancel here.

     

    4.  Finally format the volume and label it.

    If you didn't make a note of the drive letter, or didn't specify it, then first get the drive letter from the initialized disk:

    Get-Partition -DiskNumber 3

    Then format it :

    Format-Volume –driveletter “M” -FileSystem NTFS -NewFileSystemLabel "MyStuff"

    You’ll be prompted to confirm the action, and after this – the drive is formatted and ready for use.

     

    Last but not least, let’s tie all of the above into a single command, and create and format the disk in one go. This time we will create a drive N labeled “My New Stuff”:

    New-vhd –path “c:\temp\NewData.vhd” –sizebytes 3gb –fixed|Mount-vhd -passthru|get-disk –number {$_.DiskNumber}|Initialize-Disk -PartitionStyle MBR -PassThru |New-Partition -DriveLetter “N” -UseMaximumSize |Format-Volume -FileSystem NTFS -NewFileSystemLabel "My New Stuff"

    Once the drive is ready, copy the files you want to the drive. To copy folder (with its subfolders, preserving the structure):

    Copy-Item –path "C:\temp\40262\NAV.8.0.40262.W1.DVD” –Destination “N:\” –recurse
    Or copy a zip file containing everything
    Copy-item –path "C:\temp\40262\NAV.8.0.40262.W1.DVD.zip” –Destination “N:\”

    And lastly, dismount your vhd:
    Dismount-vhd –path “c:\temp\NewData.vhd”
    And the disk is now ready to be uploaded to Azure storage (we'll write about that in the next coffee break). Or copy it to another installation or site and mount it to any VM - this disk will work equally well in the cloud or on premises.

     

    Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

    Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

    Bas Graaf, Senior Software Engineer Dynamics NAV

  • Microsoft Dynamics NAV Team Blog

    Announcing Dynamics C5 for tablets

    • 4 Comments

    Dynamics C5 for tablets is now available for download from Windows Store, App Store, or Google play.

    For more information, see previous announcement of Microsoft Dynamics NAV for tablets. 

    Note: Microsoft Dynamics NAV 2015 CU1 is a minumum requirement if you are using Microsoft Azure Active Directory as the authentication mechanism.

     

    Get the app today    

    Google Play is a trademark of Google Inc. Apple and the Apple logo are trademarks of Apple Inc., registered in the U.S. and other countries. App Store is a service mark of Apple Inc.

     

    Best regards,
    The Dynamics NAV team

  • Microsoft Dynamics NAV Team Blog

    Setup considerations for the "Amendments to VAT on Prompt Payment Discounts" update for the British version of Microsoft Dynamics NAV 2013, 2013 R2, and 2015

    • 0 Comments

    This is an addition to the release note for the Amendments to VAT on Prompt Payment Discounts update for the British version of  Microsoft Dynamics NAV 2013, 2013 R2, and 2015.

    The Amendments to VAT on Prompt Payment Discounts update is based on the Adjust for Payment Discount feature, which is already part of the W1 and GB versions. However, this feature is typically not used in the GB version. Therefore, this blog post provides some information about the Adjust for Payment Discount feature.

    In earlier designs, VAT was already deducted when posting the invoice. In the current design, VAT is “adjusted” if the payment discount is deducted. “Adjust” here means that the VAT included in the payment discount amount is calculated and posted and therefore reduces the sales VAT. This happens only if the open invoice is applied by a payment within the payment discount period, or before or on the payment discount date of the invoice.

    You enable the Adjust for Payment Discount feature by selecting the Adjust for Payment Disc. check box on the General Ledger Setup page. Then you must enable the Adjust for Payment Discount feature for every VAT Posting Setup record where it must be used. On the VAT Posting Setup page (472), the Adjust for Payment Disc. field is not visible. So the user must add it with the Show Column function, or open the VAT Posting Setup Card page (473).

    Be aware that  when you have set up the Adjust for Payment Disc. feature, the G/L accounts for payment discount now come from the General Posting Setup page, not from the Customer Posting Group and Vendor Posting Group pages. Also, VAT for the payment discount tolerance and the payment tolerance is handled in the same way as for the payment discount. Also, when you apply an open invoice where the given VAT posting setup is used (within the payment discount period and/or payment discount tolerance period), then the payment discount is considered and the VAT will be adjusted. It is important that you select Payment (Refund for credit memos) as the document type on the applying entry.

    Also be aware that the general ledger entries of the payment will look a bit different than before. You will find more general ledger entries, more VAT entries, and more detailed customer and vendor ledger entries. Also, the way the detailed customer and vendor ledger entries are created is different. Now, different types are used and this can be a little confusing for users in the beginning. If you have one payment and apply many open documents, it can be challenging to understand what happened and why.

    Pay special attention to invoices that have been posted before 01st APR. For these invoices, the VAT has already been considered for the lowered base amount. If you now use the Adjust for Payment Disc. feature for these “old” invoices, then you would again reduce the VAT, which leads to wrong results. Therefore, we recommend that you use different/new VAT product posting groups for new invoices that are posted after 01st APR 2015. You can then switch on the Adjust for Payment Disc. feature for combinations with these new VAT product posting groups only. This way, payments and payment discounts for “old” invoices should be handled in the old way, and the payments and payment discount for invoices posted on or after 01st APR will be handled in the new way.

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 6 for Microsoft Dynamics NAV 2015 has been released

    • 0 Comments

    Cumulative Update 6 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2015. 

     The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    •   AU - Australia
    •   AT - Austria
    •   BE - Belgium
    •   CH – Switzerland
    •   CZ – Czech Republic
    •   DE - Germany
    •   DK - Denmark
    •   ES - Spain
    •   FI  - Finland
    •   FR - France
    •   IS - Iceland
    •   IT - Italy
    •   NA - North America
    •   NL - Netherlands
    •   NO - Norway
    •   NZ - New Zealand
    •   RU – Russia
    •   SE - Sweden
    •   UK - United Kingdom

    Note: You must convert the database if you are upgrading to Cumulative Update 6 from a cumulative update earlier than Cumulative Update 4 (build 39663). For more information, see Converting a Database in Help for Microsoft Dynamics NAV. 

    Where to find Cumulative Update 6

    You can download the cumulative update from KB 3052226  – Cumulative Update 6 for Microsoft Dynamics NAV 2015 (Build 40459). 

    Additional Information

    For information about how to install the cumulative update, see How to Install a Microsoft Dynamics NAV 2015 Cumulative Update

    For information about how to work around a recent process change, see How to Get Back the 'Hotfix Directories' from NAV 2015 Cumulative Update 1.

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2015.  

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 25 for Microsoft Dynamics NAV 2013 has been released

    • 1 Comments

    Cumulative Update 25 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013.

    The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions: 

    • AU - Australia
    • AT - Austria
    • BE - Belgium
    • CH - Switzerland
    • DE - Germany
    • DK - Denmark
    • ES - Spain
    • FI - Finland
    • FR - France
    • IS - Iceland
    • IT - Italy
    • NA - North America
    • NL - Netherlands
    • NO - Norway
    • NZ - New Zealand
    • SE - Sweden
    • UK - United Kingdom

    Where to find Cumulative Update 25

    You can download the cumulative update from KB 3051268 - Cumulative Update 25 for Microsoft Dynamics NAV 2013 (Build 40468).

    Additional Information

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013

    For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

    CustomerSource:

    PartnerSource:

  • Microsoft Dynamics NAV Team Blog

    Cumulative Update 18 for Microsoft Dynamics NAV 2013 R2 has been released

    • 0 Comments

    Cumulative Update 18 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013 R2.

     The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

    •   AU - Australia
    •   AT - Austria
    •   BE - Belgium
    •   CH – Switzerland
    •   CZ – Czech Republic
    •   DE - Germany
    •   DK - Denmark
    •   ES - Spain
    •   FI  - Finland
    •   FR - France
    •   IS - Iceland
    •   IT - Italy
    •   NA - North America
    •   NL - Netherlands
    •   NO - Norway
    •   NZ - New Zealand
    •   RU – Russia
    •   SE - Sweden
    •   UK - United Kingdom

    Where to find Cumulative Update 18

    You can download the cumulative update from KB 3052269  – Cumulative Update 18 for Microsoft Dynamics NAV 2013 R2 (Build 40452). 

    Additional Information

    For more information about cumulative updates for this version, see Announcement of update rollups for Microsoft Dynamics NAV 2013 R2.

    For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013 R2

    For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

    CustomerSource:

    PartnerSource

  • Microsoft Dynamics NAV Team Blog

    Reusable Bugs

    • 20 Comments

    Here at Microsoft we strive to create reusable and generic solutions, in order to improve efficiency and ship better software. We had revisited some of our best practice principles and had turned them upside down to get a better and more complete view on development in general.

    Description

    It widely known that bugs are unfortunately a commonly found part of software development and that there is no way to create zero-bug software. Knowing that bugs are and will stay a part of software, we have given some thought on how we can improve this aspect.

    It is difficult to come up with new and different bugs in each release, and it is a waste of resources to not use the ones which already had proven successful in the past. To avoid reinventing the wheel, we propose to come up with new innovative ways to create bugs that are reusable and generic enough to be used in various places of the application.

    Examples

    First example

    One example of a reusable bug is to find a heavily used table, like table 36 Sales Header, and observe one of the more important fields of type Option, for example Document Type. The OptionString property has the following value: Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order, which you should update to add one option, for example Transport Order in the beginning.

    The main benefit of this reusable bug is that code changed in one place, has impact in multiple sides on the application: document creation and handling, posting etc. 

    Second Example

    Codeunit 1, ApplicationManagement is a good place for creating reusable bugs. A simple INSERT on the RecRef on the first line of OnDatabaseInsert will create a sure and versatile bug that is reusable all over the application. Redundancy on database insertion ensures that data is surely conveyed to the data storage layer, twice. 

    Third Example

    We are considering to no longer make localization builds for countries. It consumes lab resources to keep running multiple country builds. Instead, we will merge everything into one single build. This is a bigger scale implementation of the "God object". Inside this unique build, we will use IF statements and sporadically CASE statements to select each country's behavior. For more help on how to use IFs, see also the IF .. THEN|ELSE C/AL Coding Guideline. 

    Fourth Example

    When you post a document, make sure that you transfer data to a field that is smaller than the field you are assigning from. This will not immediately be caught and will only hurt a subset of the customers who uses Microsoft Dynamics NAV to its fullest.

    Guidelines

    When it is not entirely obvious how you can add a bug, there is another way to approach the problem. By following some general coding best practices like the ones described below, reliable bug innovation is facilitated and can come naturally as a collateral effect.

    Code structure

    • Put everything in one function and only use comments to explain the structure of your code. And don't use functions - because this only complicates things... having to navigate from function to function, and completely lose track of where you are in the business logic.
    • On top of that .. put everything in one codeunit. Because also that will simplify and make your structure more readable.
    • Use Hungarian Notation on your variables, because at any time, you need to know what type, and what context your variable is on. 
    • Declare all your functions and variables global, so they are available at any time.

    Don’t do Unit Testing

    • Unit testing adds complexity and extra time to the stuff you’re doing. Also, it eats up extra codeunits which means: it costs money. You will never be able to foresee all scenarios possible, so you’re destined to forget and not test everything. So you will save time in not doing unit testing.

    Never add images to actions

    • Because there is an image by default. When you don’t provide an image on an action on a page, the application will foresee a ball... and when you never do it, your application will have a very consistent way of showing your actions, by providing that picture of that ball. On top of that, you’ll save time.

    Do not care about ControlIDs

    • When you’re doing development of your product, do not care about ControlIDs, and just leave the Offset ID to the default value of 0. This way, when merging, you will receive nice notifications, saying both you and Microsoft have added functions in that objects. You can use this feature to document all these places.

    Hooks

    • Never apply the Hook pattern! Hooks will only reduce upgrade time. This means, you will only shortly enjoy using the Application Merge Utilities. The more you change in default application, the longer it takes to upgrade, the longer you will enjoy the toolkit!
    • This can be taken one level higher. Simply you are not hardcore if you do not use notepad to resolve all of the merge issues.

    How to use RecRef

    • Why fuss around declaring specific table variables, just generalize, all you need is one, two, or perhaps three RecRef variables, with a few IFs and CASEs here and there for reflection, to carry you all the way.

    Arguments

    • Using only a few arguments on the functions are a sign of a weak developer. Stick in as many arguments as possible on the function, even if you are not using them, they could be useful in the future.

    Just another field / action

    • Thinking of the design is overrated, each problem can be solved by adding an additional field or the table/page or with adding another action. We all know this has worked well in the past.

    Reusability

    • We have decided that each time we fix a bug, we now also explain how it can be applied as a pattern. We then use anti-virus software to search for these patterns, to make sure we do not re-introduce these bugs anywhere else in Microsoft Dynamics NAV.

    Business logic placement

    • As a best practice, we have also decided to move code into pages. Business logic does not belong in tables and codeunits; instead pages should know and be aware of the context and update it accordingly. As opposed to tables and codeunits, pages are aware of the context. 

    Conclusion

    As the last thing, we are fully aware that this pattern would not have been approved on any other day than April 1st, and we guarantee that on no other days would we support this pattern. Happy April Fools' Day! 

    Disclaimer: this pattern is inspired from IETF documentation published on April 1st, like for example the revolutionizing IP over Avian Carriers standard.

     

    Best regards,

    Bogdana Botez, Andreas Moth, Elly Nkya, Nikola Kukrika, and Eric Wauters 

  • Microsoft Dynamics NAV Team Blog

    What Happens when You Submit Feedback to the Help?

    • 2 Comments

    Did you know that you could send us feedback about the Help for Microsoft Dynamics NAV? Did you send us feedback?

    A long time ago, we blogged about how we use the feedback that some of you send us to improve the docs for Microsoft Dynamics NAV. We still do that, so here is an update on what we do when you send us feedback.

    Primarily, we receive feedback through 2 different channels:

    • Through the "Was this topic helpful?" link at the bottom of the topics in the MSDN Library
      • 1300 people have done that in the past 5 years. 
      • This feedback is completely anonymous unless you choose to write your name, so we cannot write back to you if we fixed the issue that you told us about.
    • Through the "Documentation Feedback" link at the bottom of the topics in the Help in Microsoft Dynamics NAV, where you can rate a topic and send us email. 
      • 1000 people have done that in the past 5 years.
      • This feedback is not anonymous, but we do not share your name or email address with anyone outside the Dynamics NAV documentation team. When we write back to you, we hope you also do not share our names and email addresses with others.

    We read every single piece of feedback. If the feedback is actionable, we update the Help for the next version of Microsoft Dynamics NAV and for Microsoft Dynamics NAV 2015 in the MSDN Library. The feedback falls into the following general categories:

    • Incorrect Help content (15%)
    • The MSDN Library as such and the types of content that we publish there (24%)
    • Raves and rants about the product, a feature, , or a specific Help topic (76%). This covers feedback such as the following:
      • "Hi". 
        • Hello!
      • "La traduzione non esiste." 
        • Until further notice, we only publish content to the MSDN Library in English. Help in other languages is available in the Microsoft Dynamics NAV product. But we do appreciate that a lot of you would like to see translated content in the MSDN Library as well, and we are investigating what we can do.
      • "Where is the white paper!" 
        • There isn't one. We do not publish Help content as downloadable PDF files anymore.
      • "Explain why the refresh button is not active." 
        • We have no way of knowing what might be wrong with your data connection.
      • "Mumbo Jumbo"
        • Eh, OK....
      • "I had an Error: Could not locate the add-in library for "Microsoft.Dynamics.Nav.Client.BusinessChart;PublicKeyToken=31bf3856ad364e35, The page contains a control add-in that is not permitted. Contact your system administrator". How to fix this error?" 
        • By contacting the system administrator, who might then have to contact Microsoft Support.
      • "Thank you. The C/AL function list is exactly what I was looking for."
        • You're welcome!
      • "Was searching for something else and found this little gem. Very useful when working across several servers (Live, Dev, and Test) and being able to identify exactly what environment you are in."
        • Thanks! We like the System Indicator functionality, too!

    We hope you understand that we especially appreciate feedback that helps us weed out bugs in Help or in the product. Some of you also take time to give us praise for a topic that was truly helpful to you, and we're not above being flattered by that, so thank you!

    But we appreciate all feedback, also when you tell us that our content in the MSDN Library should be available in languages other than English, or that you expected to be able to read about other scenarios than the ones we covered, or that the link to PartnerSource is broken. Some of you also take the time to tell us that you do not like a Help topic, or a feature in the product, or the product as such. We are always sorry to read that, but we are especially sorry that we cannot contact you to learn why you were so frustrated at the time.

    No matter why you choose to send us feedback, we would like you to continue. All feedback is processed, all feedback is taken into consideration. So please keep the feedback coming!

     

    Thank you for your feedback so far!

    Susanne, John, Soren, and Eva from the Dynamics NAV documentation team

Page 1 of 50 (744 items) 12345»