This blog is the first part of how you can automatically upgrade Dynamics NAV through PowerShell.
With release of every new version of Microsoft Dynamics NAV, Microsoft offers enhancements and new features. For upgrading to Dynamics NAV 2016, you need to upgrade your code and database both to the new version. Usually manual upgrade process is tedious and takes much of your time. Microsoft introduces new concept, – “Automatic Upgrade through PowerShell”. Doing Upgrade process by Windows PowerShell will make your work very easier and also save lot of time.
There are mainly two steps in upgrade process:
During an upgrade to Dynamics NAV 2016, you must first upgrade the application code, and then you upgrade the data. By using Windows PowerShell, you can automate upgrade application code process and complete data upgrade process in a single click. You can also use the same scripts to test each step in your upgrade process before you upgrade production databases.
If you are maintaining multiple Dynamics NAV databases, for example you are supporting multiple customers with the same Dynamics NAV application, you can reduce the time of upgradation of each database by using Windows PowerShell scripts. In this case, you can upgrade the application locally, and then use scripts to roll out the upgrade of each database with reduced unavailability for each database. You can combine this automated upgrade with a migration to multi-tenancy if this makes maintenance easier for you.
To start the upgrade process, create four folders on your computer and name them as follows:
The following list describes the main steps of upgrading the application code:
To create the application for the new database, you must merge these three sets of application objects. You can use the Merge-NAVApplicationObject cmdlet to merge the three sets of application objects.
There are three process performed by the system when automatic merging process executed through PowerShell: Reading Objects, Comparing Objects and Writing Objects.
Merging time might vary depending on the number of objects that you are merging and the number of differences found. The RESULT folder will contain a text file for each application object. The result of the merge is shown when the cmdlet completes, including a description of any application objects with conflicting code. These conflicts are stored in .CONFLICT files in the RESULT folder. You can import all objects in the RESULT folder into the new Microsoft Dynamics NAV 2016 database, or you can analyse the conflicts before you import the objects.
As per the image below, the automatic merging process through PowerShell is executed and after completing this process, system will generate the Summary related to Automatic Merging Process.
System also display how many percentage merging has been done.
Depending on the application that you are upgrading, you can choose to analyze the conflicting code before you import the merged objects into the development environment. The conflicts are shown in the merged text files but are also identified in .CONFLICT files in the RESULT folder. Subfolders then contain copies of the source files from the versions that have conflicting code. You can analyze the conflicts in any tool, make the relevant changes, and then run the merge operation again.
Alternatively, you can import the merged files into the development environment, and resolve the conflicts there.
After completing the merge, import the new custom version into the new Microsoft Dynamics NAV 2016 database, and then compile all objects. Resolve compilation errors, if any, before you can continue. The text files with the merged application objects include successfully merged code, and code that is partially merged. You can import the partially merged objects into the Microsoft Dynamics NAV 2016 development environment and resolve the conflicts there. At this stage, you have a new database with a fully upgraded application.
For example, the Microsoft.Dynamics.Nav.Model.Tools.psd1 module includes a function, Import-NAVApplicationObject, that runs the ImportObjects command. This means that you can run a command such as the following:
In this example, you first join the many text files into a single file, which you then import into an existing, empty database. When you compile the objects, an error is thrown for each code conflict, and you can use the tools that are available in the development environment to resolve the conflicts.
Now, export all objects to an objects.fob file to import them when performing the data upgrade. The export must include customized objects, upgraded reports, and all other Microsoft Dynamics NAV 2016 objects.
This completes the upgrade of the application code. Read our upcoming blog to learn how to upgrade the data in the database.
For more details, contact our Dynamics NAV consultants.
As businesses grow and projects multiply, managing invoices efficiently becomes crucial. In the 2024 release wave...
Exploring Trends for AI in CRM and ERP Systems [2024] Did you know that a...
Efficient data management and analysis present significant challenges for businesses operating in the current data-driven...