NAV TechDays 2014

This great venue finished last Friday.  As usual it was a success and the number of attendees skyrocketed up to 780.

I met a lot of friends and found some new.  Would have loved to be able to invite all the attendants to look a Objects4NAV.com and see if we can get more people to contribute.

Some things are best said with pictures.  This video is by Kai Kowalewski and is published on YouTube.

Thanks – see you next year.

Give our customers NAV 2015 Demo with own data in few steps

Microsoft just released the Cumulative Update 1 for Dynamics NAV 2015.  With this update we no longer need to push our data upgrade through NAV 2013 R2.  As the blog says:

“The cumulative update includes an upgrade toolkit for upgrading a Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 database to Microsoft Dynamics NAV 2015. The upgrade toolkit includes several application objects in FOB files that simplify the upgrade process for those of you coming from Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1. For more information, see the attached whitepaper.”

Attached is the new PDF document on how to upgrade NAV 2009 R2 or NAV 2009 SP1 Database to NAV 2015

The biggest task in the data upgrade from a customized database to a standard one is to handle all the data modifications.  For this I use the Table Compare tool.  I need both the customized version and the old standard version.  Export all tables from the Object Designer to a text file and import into the tool.

ImportTableData2015

Also import the 2015 objects in a similar way.  After importing all the table definitions into the tool and selecting the appropriate Base Version for each customized version go into the Version Comparisons.

VersionCompare1

After pressing the Compare button the result is showed.

VersionCompareResult

Click on the counters to drill down to the tables.  For all the tables listed as modified and deleted select the action to force the data transformation.

ForceTables

Back on the Version Comparison click the button to Create 2015 Upgrade Code and Save Codeunit Object File.

SaveUpgradeCodeunit

 

Now we step over to the data upgrade task.  We follow the guide by Microsoft; prepare the 2009 R2 version, convert with 2013, open with 2015, compile system tables, attach a service, run the schema synchronization and import the 2015 application objects.

Here we stop after step 21 and add our exported upgrade Codeunit by importing and compiling.  Now, run the Sync. Schema for All Tables With Validation.  This should clean all fields that are not a part of the standard NAV.

Sync

Remove the custom upgrade Codeunit from the database and continue with step 22, Import Upgrade601800.[Country].fob and so forth…

Continue the Microsoft steps and you should have a 2015 version database ready to use as a demo database for the customer.

p.s. This method will also apply to any upgrade process from 2009 R2 to 2015.  If there is customization in the 2015 database, just use the tool to create a temporary tables and data transfer code.

New renumbering tool with DotNet power

No, there is not a dotnet add-in, just using dotnet in C/AL.

I have made updates to this tool.  Read about it here.

There is an old version of a renumbering tool on this blog.  It works in the classic client but who uses the classic client any more ?

I wanted to upgrade this tool to NAV 2015 (and NAV 2013 R2).  There where a few issues that I needed to handle.  First; how to upload a large object file to the server, how to read through millions of lines to find what I was looking for, how to replace string in all these lines without having to wait for days.

That is what I did.  One Table and One Page.  The code is all in the Table, not the ideal setup but I preferred fewer objects over prettier design.  On the other hand this it not that big of an object so every developer should find the way through the code in there.

I have been sharing objects on this blog and have also started to share and sell objects on Objects4NAV.com.  These objects are all in the range from 50.000 to 99.999.  This tool will make it so much easier to import these objects into the database.  Just download the renumbering tool and manually install it into the database and use the tool from there.

A little spoiler, I just used this tool on an object file with just under four million lines and needed to renumber 116 objects.  The tool completed this in two minutes and forty two seconds.

So, how does it work?

RenumberingPage

The page has only three columns.  Source object type, source object id and the new destination id.  If you leave the destination id blank the line will be ignored.  If you need to renumber an object to a number that already exists in the database start by renumber the old object before reusing the object id.

In here we have five functions:

  • Read Object Lines will populate the renumbering lines from an object file.
  • Suggest IDs will look for available id by searching the license permission and will update the renumbering lines.
  • Write to Excel will export the renumbering lines to an Excel worksheet.
  • Read from Excel will import the same format from an Excel worksheet.
  • Update  Object File will apply the object changes in the renumbering lines to an object file and will save a new object file.

If you have this tool in the customer database then you can import the object file you want to add to the database, get a suggestion for new ids, export a new object file and import that one into the database.  This will only take a few seconds.

Lets take a closer look at the code.  Perhaps that will help you in some of your ongoing task or in the future.

The first thing that the tool does is to upload the object file to the server temporary folder.  In NAV we have a function for this purpose but that one can only handle a limited amount of data.  A four million lines of code will not be uploaded with the standard method so I had to create another one.

UploadFileToServer

The magic word here is streaming.  This code will take 4KB of data in each portion and upload to the server.  It will repeat until done and I don’t think you will find a useful NAV file that will not be uploaded with this code.

Once the file is on the server the tool loads the whole file into memory.

LoadFileIntoMemory

An array of string is used to store all the object lines.

This is the starting point.  From this point I can loop through all the lines and do what ever I want.  However, doing that line by line will take forever so I have applied a few tricks on the way.

When the tool is loading an object file into the renumbering lines it will use the dotnet string function split to break the line into smaller bits.  When the tool finds an object it will search the string array for the end of that object before continuing and can therefore skip all lines except the ones needed to build the renumbering lines.

When renumbering, instead of applying each renumbering line to every code line, the tool combines five thousand lines into one dotnet string variable and uses the dotnet function replace to update the code.  After each chunk of code is updated it is downloaded from the server to the client side and written to the local file system.

ReplacementCode

Well, what are you waiting for.  Download the renumbering tool and start using it today.