Converting Dynamics SL BSL to VBA

Dynamics SL 2018 doesn’t support BSL screen customizations any more. These must be converted to VBA. Contact third-party vendors to obtain updated scripts when appropriate. Here are steps to convert All User, One Group, and Self customizations. Do this in non-production databases, of course.

The first step is to export the BSL components from the old environment using “Export Customizations (91.500.00)”. Select all the BSL customizations at the levels above and save the “CST” file. You can edit it with a text editor.

Separate the customizations into two files, one with code and one without (only containing properties). The easiest way I’ve found to do that is to search for “End Customization”, then look just above that to see if it’s immediately proceeded by BSL code or a property.

If there are no customizations that contain code, or in the file that has no BSL code, use the text editor to change all references to “Version: 2” to “Version: 6”. Save the file and import it using “Import Customizations (91.510.00)”.

This SQL script will quickly show the customized screens from the system database Screen table:

SELECT DISTINCT S.*
FROM Screen S
JOIN Custom2 C
  ON S.Number = C.ScreenId

Open each screen with custom code using the appropriate customization level (often the All User level). Enter customization mode and press F7 or enter the VBA editor. A dialog box will appear asking if you want to translate the code to VBA. Answer “Yes”. The VBA editor will display the translated code.

Review the Modules to see if there are any table (or type) definitions, which are shipped as files with a “dh” extension. These will have the keyword “Type” near the top and declare two variables that have the type name starting with “b” and “n” near the bottom. Dynamics SL ships these in the …\SL\Applications\DB\DHFiles folder for either the application or system database. Right-click Modules and Import the file that starts with the type name and has the extension “dh”. You’ll need to change the “Files of type:” drop-down the “All Files” to see them. After importing the definition for the current version of SL, remove the type definition from the old version, saving if desired.

Sometimes a developer may have renamed a type definition so it doesn’t match the database table name. You may be able to find a similarly named table. In a recent upgrade, for example, the developer had renamed the type of the APDoc table to APDocPO. After importing APDoc.dh, I changed APDoc to APDocPO in that module, including the buffer variables starting with “b” and “n”. It’s a good idea to compare the old exported type with the new definition imported from the .dh file using something like WinMerge to insure the two definitions are the same except for schema changes between the old and new versions of Dynamics SL.

Repeat this for all the type definitions except those that start with the letter “x”. Types that start with the letter “x” are custom types and will need to be manually edited if the table definition has changed. If so, chances are that you’re already working with a developer and he or she will upgrade the customizations for you. Keep an eye out for “Update1” events. They’ll need to be edited as I described here.

Dynamics SL 2015 didn’t install BSL components by default and they’re required to update open screens with BSL customizations (earlier versions always installed them). The 2015 GA (General Availability) release contains an AdditionalComponentInstallers folder containing BSLComponents.msi. Run that if you see System Message 20227 “Attempted to load BSL customization but BSL components are not installed.” Chances are that your upgrade environment already has the BSL components installed.

After converting all the BSL customizations to VBA export them, making sure to check “Export VBA as Source” for readability. Then you can delete the old BSL customizations from the Custom2 table.

Finally, it’s important to visually inspect the customized screens, especially if upgrading more than two major versions. It’s common for group controls to change names and often customized controls will need manual adjustment to move them to the appropriate position.

When you’re satisfied everything looks good on all the customized screens, export all customizations again so you have a backup. If the upgrade environment is different, import the file you just exported there.

Leave a Reply