If, like me, you’ve committed yourself to a world of source control for your NAV projects, you’ve probably got repository upon repository just filled with text files, each one representing one of the 4,500 – 6000 objects within NAV, plus all those wonderful third party add-ons, custom solutions & other assorted dross with which we fill a database.
When it comes to migrating or upgrading these changes, you may decide you only want to start reviewing or processing those objects which have been modified. For my part, I’m in the process of converting a modification from 2017 to an extension ready to go on BC. Fortunately, this was always planned to be a stand-alone product, so was developed & kept in it’s own branch in our TFVC repo.
However, as per our standard process, this repo includes all nav objects for the database it was developed upon.
I now wanted to load those objects into a clean, shiny database (created in a docker container, using the standard MS images, of course) and rather than load all of those objects & suffer the tedium that follows, I wrote a script to identify objects within the branch which have been modified, and then I only need to load those objects into my base application.
Now, this is not the neatest or most efficient way to do this, and I’m certainly not the powersell guru that @waldo1001 is, but it works nicely with the setup I already have, and gives me the option to either run this for a single file containing all text objects, or a folder with one object per file.
In short, you provide a file path, the system identifies if this is a file or a directory, and then creates a variable filled with all the text files.
It then creates a nice clean target folder, runs through the objects & identifies if they have a ‘Time’ element that is equal to ’12:00:00′ or does not have a ‘Modified’ property tag. If both of those conditions are not met, then the file will be moved to the copy directory.
It should also be noted that this work is building upon works done by my undauntable colleague & confident James Pearson to split text files into individual files, so I could not take sole credit.
I expect to find quite a lot of use for this as we transition from C/Al to extension, and hopefully it will be of some help to you too!