«

»

Print this Post

Merging NAV Versionlists to NAV 2017 – Updated PowerShell functions!

Soon will be the release of NAV 2017. And I assume you are going to want to upgrade to it. :-).  Let me save you from one upgrade-caveat ..

A while ago, I blogged about merging VersionLists with PowerShell. It shows a solution on how to handle (merge) version lists with PowerShell.

Judging from the amount of reads, it has been “used” quite a lot. I use it not daily, but at least every month .. to apply the Cumulative Update. You have been able to find the scripts on my github.

Some time ago, a great developer from the Netherlands called “Jan Hoek” created an issue on my github, telling me the function contains a bug. One I wasn’t aware of .. but he was very right.  Thanks for this! :-).  By the way, Jan has got a blog which you should check out!  Here it is: http://www.uncommonsense.nl/zen/

The function is going to compare strings, like NAVW19.00 is greater than NAVW17.10 . This has worked, but only …

… until NAV 2017

Because NAV 2017 is version 10. Which means in the version list it’s NAVW110.00. If you do a text comparison with this, you will see that NAVW19.00 is greater than NAVW110.00. This is an issue, because merging version lists to NAV 2017 was all of a sudden not possible anymore.

Solution

There is a solution, and it’s already on my github. I changed one function, and added another one. Basically, I needed to be able to compare integers instead of strings. These are the two functions I’m talking about:

I changed “Merge-NAVVersionList” to loop the versionlists, compare them with the next one, and “bubble up” the one that I want.. .

And I added “Get-NAVHighestVersionList” to figure out which one is the highest versionlist of two, based on a prefix you provide:

(Thanks to kfuglsang for contributing to this, and already providing a bugfix – I love the community 🙂 )

Probably, there are better ways to do this.  I’m always open for suggestions.  But for now, I hope this works for you :-).

You can test both functions with code like this.

And the other one like:

Your upgrade code can still stay the same – the signature of the main function “Merge-NAVVersionList” hasn’t changed, so you should not have to change any scripts – only these functions.

Enjoy!

5.00 avg. rating (97% score) - 2 votes

Permanent link to this article: http://www.waldo.be/2016/10/24/merging-nav-versionlists-to-nav-2017-updated-powershell-functions/

4 comments

2 pings

Skip to comment form

  1. Kristof

    Oh no, not my Again 🙂

    Hi Waldo, I think i found a small bug in the loop here:
    I’m Merging W1 with CH NAV. [Better don’t ask why]. The problem i’m facing right now is the follow:
    COD1:
    W1 : NAVW110.0.00.14199 vs. CH: NAVW110.00.00.14199 [2 x 00]

    this leads to an empty HighestVersionList in return. Why? Well: you compare the string in the top which is not equal:
    if ($VersionList1 -eq $VersionList2)

    due to that you run into the Integercasting this will flatten the 00s to 0. like this the code within the loop for ($i=0;$i -lt $Count;$i++){…} will never detect a difference and the return value will be empty.

  2. Mike

    It doesn’t run properly. It has got a syntax error. After correct it, the result was:
    NAVW110.00,NAVBE7.10.00.37563,NAVBE7.10.00.37563,I7.4,M22344,M65877,I8.0,NAVBE10.00

    It creates all version lists concatenated!

    1. Mike

      Sorry, if a prefix doesn’t set in MyVersionPrefix returns all version list, It’s Ok. Thank you. It runs properly

    2. waldo

      Cool :-). thanks for getting back 😉

  1. Merging NAV Versionlists to NAV 2017: Updated PowerShell functions! – Oct 23, waldo’s blog, #MSDynNAV

    […] Continued on Source: Merging NAV Versionlists to NAV 2017 – Updated PowerShell functions! » waldo's blog […]

  2. Merging NAV Versionlists to NAV 2017 – Updated PowerShell functions! | Pardaan.com

    […] Bron : Waldo’s Blog Lees meer… […]

Leave a Reply

%d bloggers like this: