Step one is to create a new repository. We’ll do that from Visual Studio using the plugin.
As you can see in the screenshot I am connected to my GitHub account.
Here I select Create and populate the window like this:
And this creates a new Repository on my GitHub Account
Adding NAV Objects to Git Repository
Next job is to add some NAV code.
For this project I want to have four folders since the workshop has four exercises. I want to develop the exercises indepentantly even though they are build on top of each other.
In this project I don’t care about standard Microsoft objects. I don’t want to make this more complex than it already is. I am not a big fan of building code repositories that start on CRONUS objects. I’d rather do deltas in that case. Let’s keep it simple and put the text files on GitHub that people have to import in their NAV2016 database.
I simply create four folders in my explorer where Visual Studio has put my project and put all the files there I want to be on GitHub. I have created a file per object using Soren Klemmensens vbs script, no need for PowerShell.
If I now go to my Changes windows in Visual Studio you can see it found 150 new files.
Smart tool! Now we select Add-All and put something in the Commit window and see what happens.
On GitHub, nothing happens. That is the funny thing about distributed version control. I can commit changes, and revert changes on my local machine without my co-workers see what I do.
I can see the commit hash and the infamous train tracks start to appear:
Sync to GitHub
All I have to do now, is to Sync to GitHub and my changes will be there, for everyone to download and change.
The challenge I have is the following: I want to share code examples from Dynamics NAV in a structured & dynamic way. They are subject to change and improvement. I want people to able to download them, report bugs and if possible fix the issues themselves.
Visual Studio Team Services
About 18 months ago I blogged about the availabilty of Visual Studio Online, or VSO.
This has since a few weeks been renamed to Visual Studio Team Services. Makes a lot of sense, since it is TFS in the cloud. Visual Studio Code is something else.
We are wondering off. I’ve been using VSTS for almost every project since it was released. It is easy to get started and allows you to combine strong agile project management tools with version control. Once you get the hang of it, it is very easy to use with Dynamics NAV.
Visual Studio Team Services is secure. When I do a customer project it allows me to assign who has access to the code and to the work items. Perfect for a project
In this specific case, I want the opposite. I want everyone to access my code, download and improve it. Hence I was thinking of GIT.
As you might have noticed in my blog post from a couple of days ago I am making an attempt to print an existing PDF from NAV.
This is a common request. For example: print assembly instructions together with a sales packaging document. The assembly instructions are an existing PDF document and the sales document is generated by NAV.
In the classic client I used a command prompt tool for this, but I figured this would be possible using a DotNET component in newer versions such as NAV 2016.
Finding a tool
Step one is to find a tool that lets you do this. I searched in NUGET packages to see if something existed. I decided to try one I found, Spire.PDF. I guess there are more tools, maybe better ones. If you have a better one, please tell me.
Step two is to install the DLL. This is explained in the previous blog.
Writing the C/AL
Last part is to write the C/AL DotNET code that prints the PDF. This starts by finding the constructor.
The easiest way is to find some C# code to copy. This is what I found on StackOverflow.
Microsoft is trying to make our life easier from an upgrade perspective with merge commandlets and upgrade codeunits. This is nice but sometimes you run into situations that are not fixable with tools like these.
I am currently upgrading one of my older customers from NAV2009R2 classic to NAV2016. Some code goes back to 3.60 and reports to 2.x.
During this upgrade I run into a number of issues that are disruptive to merge commandlets, even if I were using pages, even if I were using extensions and eventing.
This has everyting to do with Microsoft refactoring. There are three major application areas they have refactored that blow up my upgrade.
This post is about SMTP Email. Dimensions we all know, I don’t think I have to write more of that.
To “fix” sending emails with SMTP there is a shortcut and a “new way”.
Let me show the shortcut first.
In NAV2016 the function AddAttachment has one extra parameter
Simple fix. But if you want SMTP in NAV2016 you really should use something else.
Arguments Table | 9500 Email Item
As I mentioned in my post, Microsoft is starting to use a table as a class grouping arguments in a table to pass into a function. This is called “argument tables” and described in my blog and Master Class.
Please note that I also use a very old version of notifications. This was discontinued somewhere after Navision 4.0. I have to upgrade this to the new Notification. Another thing that broke my “Easy Upgrade” since it was bringing in objects with name conflicts.
There is a small naming issue. “Send to” should have been “Send To”. Must have slipped code review.
The Arguments table also does not support multiple attachements.
If you want to send your email in HTML format, you cannot open it in the UI. This is the (TRUE) parameter of the Send method.
Remember my dear students in the Master Class! UI Separation. 😉
“NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.”
So Microsoft Dynamics NAV with C/AL is part of the Microsoft Development Platform. (Ugh Ugh Ugh). So how do we use it.
Arend Jan Explains:
In VS we have to create an empty project. Just create a C# Console project.
Open the package manager console View -> Other Windows -> Package Manager Console
In the window we get now we copy and paste the text from the NUGET page. In my case I want to use a PDF package to see if I can print PDF from NAV. (You can guess my next blogpost).
This is what we should have in the window after executing the command:
So we can go to our project folder and get the DLL, and place it in the Dynamics NAV Add-In folder.
NAV 2016 Cumulative Update 2 is released. I have to admit, normally I don’t pay that much attention to updates, but the last ones are on my radar because of some promisses.
Nobody could be happier with the new code editor than me. It makes me more productive and makes our environment sexier and more attractive to young people.
However, the very first piece of feedback I gave was that in some cases the Symbol Menu was not bad.
This feedback was first ignored during the Technical Preview process, but due to pressure after release it is now back.
Glad I was not the only one.
Events & Extensions
There are a couple of interesting KB articles in CU2. Mainly about Extensions and Events.
You cannot publish an extension if it contains too many objects.
So somebody is trying to wrap their entire vertical solution in an Extension? 😉
An extension object cannot be added when a deleted base object had the same ID.
This is a strange one. First and foremost, if you package an extension ALWAYS use ID’s in you CfMD range. I don’t recommend packaging custom objects as Extension.
You can change the automatically generated ID in the Database-Alter menu on the Advanced Tab.
I admit, it does not work too well with distributed development where each developer has their own database.
Hopefully in the (near) future Microsoft will make the required changes in NAV to make proffesional development easier out of the books so we can safely say distributed development is easy. I would also like to see GIT support.
Microsoft is trying to make our life easier from an upgrade perspective with merge commandlets and upgrade codeunits. This is nice but sometimes you run into situations that are not fixable with tools like these. Continue reading “Excel Buffer & Ease of Upgrade”