Form Transformation – Tips And Trics (1)

Although with fourteen years of experience in NAV development, I never could get myself to start with a blog. After all, what is it that I know of NAV that isn’t known by any other developer? Still, my former teacher and now colleague Luc van Vugt  encouraged me to start writing a blog myself. So here’s my first try.

I’m currently working on the project of making our add-on I-Fresh ready for RTC. While running the transformation tool I ran into some old coding habits. For example, to set the visibility of a form control, I usually type something like this:

CurrForm.MyControl.VISIBLE(<Some statement>);

Here’s where I got into trouble while converting my forms to pages because the transformation tool only supports the following syntax:

CurrForm.MyControl.VISIBLE := (<Some statement>);

The same problem occurs with CurrForm.MyControl.EDITABLE.

To get around this problem I started looking at the “Coderules.txt” file that was shipped with the Transformation Tool. It is possible to edit this file and create your own transformation code rules . After some tweaking, I found out that the transformation tool uses the Coderules.txt file the same way as a firewall uses its security rules. Rules that are put first in the file will be executed first and you can transform your code in an early rule so that it matches one of the later rules.

By default, the transformation tool transforms  “CurrForm.MyControl.VISIBLE := (<Some statement>);” into “MyControlVisible  := (<Some statement>);”. Note that the MyControlVisible is a new Boolean variable with the property “IncludeInDataset ” set to TRUE. For more information Mark Brummel wrote an interesting blog about this property.

That is done by this standard rule:

!currForm!.!var1!.VISIBLE :=
!declaredVariable! :=

In short, the rule creates a Boolean variable with “IncludeInDataset” set to TRUE. Links this variable to the control and sets the variable to change the property of the control. Now, to get my incompatible code working I added the following rule to “Coderules.txt” at the top of the file:

!currForm!.!var1!.VISIBLE := (

Save the file and now your transformation tool also supports the CurrForm.MyControl.VISIBLE(<Some statement>); code lines . Hey Microsoft, this might be a usefull addition to the standard rules! Smile

Comment List