Upgrading a NAV AddOn is not solely merging code and upgrading the database through all NAV versions in between source and target. It involves analysis and prototyping of present AddOn features into features existent in the latest NAV versions. We often ask ourselves how can we replace feature X in our AddOn hosted on a NAV 2009 installation with the new feature Y in NAV 2017?
Sometimes the answer is Yes: we can merge AddOn functionality with existent features in standard. The benefit is major.
Take Comment Line table for example. Almost any AddOn has a storage place for AddOn entities to record comments or notes.
Why keep them recorded in a table in ISV’s range when we could take advantage of an existent standard table perfect for this purpose? Table Record Link was introduced in NAV 2013 and can keep track of notes and links.
The short demo below assumes the existence of:
- a table “Generic Entity”
- a table “Generic Entity Comment”
- a card page “Generic Entity Card”
- a list page “Generic Entity Comments”
- codeunit “Upgrade Notes 1”
To generate notes for each comment in table “Generic Entity Comment” run the codeunit 90003″Upgrade Note 1″.
The text itself resides in a Text field in “Generic Entity Comment”, but “Record Link” table has a BLOB field for recording the text. Therefore I needed to move text from “Generic Entity Comment”Comment field into a BLOB field in “Record Link”.
I wanted to use .NET here not only for exercising my rusty .NET muscles, but recording Danish characters in a BLOB proved to be a non-trivial job. So I used MemoryStream class with BinaryWriter which comes equipped with character encoding capabilities.
For a simple demo follow steps 1-4 below:
Code used is available for download here.