Merging Legacy Systems
In this chapter you can read about Merging 2-Control in different Dynamics NAV versions, Customize NAV for multiple addons and Licence checks.
Merging 2-Controlware code in NAV 3.xx-2009
The last version of 2-Controlware for Dynamics NAV 2009 R2 is 7.00. Contact us if you need to download objects for these version or older.
For the customization of Dynamics NAV 2013 up to including 2015 see Merge 2-Controlware code in NAV 2013 up to including 2015. For NAV 2016 and up no merge is required because eventing is used.
For the 2-Control Compliance modules Field and Dataset Security and Mandatory Fields a separate activation is needed.
Your Microsoft NAV Partner needs to customize some lines to Codeunit 1 Application Management and 423 Change Log Management. After these customizations the 2-Controlware modules are ready for setup and use. For the other modules no merge is required.
Important! If you have changed the default setting for the change log in Compliance Setup, you have to call the change log functionality in codeunit 1. See General Compliance Setup.
Merge 2-Controlware code in NAV 2013 up to including 2015
Important! For the customization of Dynamics NAV 3.xx – 2009 see Merge 2-Controlware code in NAV 3.xx-2009. For NAV 2016 and up no merge is required because eventing is used.
To activate the modules
- Field and Dataset Security
- Mandatory Fields
Your Microsoft NAV Partner needs to customize some lines to Codeunit 1 Application Management, 40 LogIn Management and 423 Change Log Management. After these customizations the 2-Controlware modules are ready for setup and use.For the other modules no merge is required.
Important! If you have changed default setting for the change log in Compliance Setup, you have to call the change log functionality in codeunit 1. See General Compliance Setup.
Customize NAV for use with multiple addons
To enable multiple add-ons to use Codeunit 1 on NAV 2015 and older, a specific code merge is necessary. This needs to be reviewed per customer or installation as circumstances differ. The code merge as described in our manual is only an example useful if no other add-ons are used. As we use eventing in NAV 2016 and newer, no code merge is necessary. The code merged to Codeunit 1 for 2-Controlware fills a temporary memory table at login, holding the field security configuration for the user. The function GetDatabaseTableTriggerSetup checks whether field security is active by using database triggers. It sets four booleans to determine which triggers are executed:
- OnDatabaseInsert;
- OnDatabaseModify;
- OnDatabaseRename;
- OnDatabaseDelete.
2-Controlware can be used in conjunction with other add-ons in Codeunit 1. To do this the code required for the add-on needs to be merged in such way they do not interfere. Our add-on checks the four booleans in one run, however other add-ons might not do so. These are the steps required to combine the 2-Controlware add-on with other add-ons in Codeunit 1:
1. By default the booleans are FALSE;
2. Create four local booleans in the function to store the most recent value, one for every trigger;
3. Execute the code of the first add-on;
4. Copy the values of the default booleans in the local booleans;
5. Check whether at least one of the four is still FALSE:
- If not, EXIT: everything is TRUE, there's nothing to check;
- If there are, execute the next function and compare the default and the local booleans:
- If local = FALSE and default = TRUE, then local becomes TRUE;
- If local = TRUE, then nothing;
6. Do this for all add-ons.
These steps sum it up for all add-ons. The basic assumption is that an add-on only converts FALSE to TRUE, never the other way around. Converting from TRUE to FALSE would not be logical because FALSE is the default value. Apart from that, once a boolean is set to TRUE it should remain TRUE for that specific add-on. To recapitulate: changing TRUE to FALSE is not possible. Another risk is that partners might do more than setting booleans in Codeunit 1. In such occasion you have to execute all code and copy the local booleans to default booleans, instead of EXIT. Lastly, 2-Controlware checks the changelog in our own Codeunit by default. You probably do not want this when using multiple add-ons. With recent versions of 2-Controlware you can configure this in the table 2C Compliance Setup. It holds an option to configure where the changelog is checked: Codeunit 2CW or Codeunit 1. You choose the last option there to change this.
Licence checks
If you are merging code of 2-Controlware into NAV 2013 up to and including NAV 2015, without a license for the 2-Controlware modules present (e.g. developer license of another add-on supplier), a license check is required. For NAV 2016 and up eventing is used. Because only for the modules
- Field and Dataset Security
- Mandatory Fields
a merge is needed, this code will initially only be of interest for Codeunits 1, 40 and 423 (see Merge 2-Controlware code in NAV 3.xx-2009and Merge 2-Controlware code in NAV 2013 up to including 2015). If visibility code is added on Forms or Pages, the license check is also relevant here (see Customization for Field and Dataset Security (Forms)and Customization for Field and Dataset Security (Pages)).