When working with NAV, you’re familiar of working with objects. And nowadays, we have quite a lot of options, like:
- Fob file
- Text file
- Split text files
- Reverse Delta’s
- … (more?)
Depending on the situation, you might be interested in one of these kinds of exports – if not all.
Now, I have been working on some small pieces of functionalities (let’s call them “Extensions” ;-)) in NAV, like the Rental App that was shown at Directions and my very own new NAV2016 version of “WaldoNAVPad” (which is still under development, but can be obtained from GitHub here).
Now, doing these kinds of extensions, I wanted to move them to new development environments, new versions, localization, .. . So as such, it’s not really a collection of objects, but more like a collection of deltas. So I decided that my structure on my GitHub, should always contain all types of object files, in all formats that might be useful to me in the future. Does it make sense? Sure I know you can generate delta’s from textfiles (IF you have the original) – or the other way around. But I don’t really care. If I can generate it on the fly .. then I will, and just save it all. In this case, I always have everything at hand if I need it. Simple as that.
I have dedicated myself in making it myself as easy as possible. All I do to save my developments to GitHub, is running a very simple PowerShell script, which you see here:
$Name = 'WaldoNAVPad'
$DEVInstance = 'WaldoNAVPad_DEV'
$ORIGInstance = 'DynamicsNAV90'
$WorkingFolder = 'C:\_Workingfolder\WaldoNAVPad'
$BackupPath = 'C:\Users\Administrator\Dropbox\GitHub\Waldo.NAV\WaldoNAVPad'
$CreatedITems = Backup-NAVApplicationObjects `
-BackupOption OnlyModified `
-ServerInstance $DEVInstance `
-BackupPath $BackupPath `
-Name $Name `
-NavAppOriginalServerInstance $ORIGInstance `
As you can see – only one function that gets all parameters. And the result is a fixed folder structure on my gitHub:
So, one change in one line of code, probably is going to end up in 5 files.
Is this ideal? Probably not. One line of code should be one change in your SCM. But do I care? Well .. I do, but I don’t think it is that big of a deal: my script will keep everything in tact: all 5 files will always be changed and be up-to-date .. and the benefit from having all kinds of files available in any situation is definitely making up for it :-).
I’m interested – tell me how it works
The function is available in my PowerShell Module on GitHub, so I strongly recommend you to install the module for you to be able to use it. But let me shortly tell you how it works. The functions are quite long, so I won’t post it here – you can have a look at the up-to-date version here.
Basically, the function will:
- Export objects in fob and txt from the database, that is attached to the provided ServerInstance
- Manage only the modified objects (this is how I do it)
- IF you provided an Original (NavAppOriginalServerInstance), it will start to create delta’s, with the function “Create-NAVDelta“
The Create-NAVDelta, is a story on its own. This function is going to use a workingfolder, because it will:
Export all objects from original and split them
- If already done so: it’s not going to do it again, and it relies on the workingfolder
Export all objects from modified and split them
- If already done so, it will not do that again, and only going to export the modified, split them to the split folder – modified is up-to-date
- Create delta’s
- Create reverse delta’s if necessary
- The Backup-script will copy all the necessary files to the backup-folder (In my case, the GitHub).
The moment I run the Backup-script above, my GitHub gets updated, and I can beautifully see what I changed in my small application. Just have a look at this example, where I fixed a simple bug.
This post is not supposed to form any opinion on Source Control Management. It just mentions how I “source control” my developments in my free time.. . The focus of the post, is the script that is simply going to produce all types of exports there are.
The links to my GitHub might change, as I restructure occasionally. In that case, leave me a comment and I will update this blog, and/or just browse to my main page, and start from there: https://github.com/waldo1001/. But again, I’d recommend to just simply install the module.