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:
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:
<find>!currForm!.!var1!.VISIBLE :=<declareVariable>!var1!Visible<declareVariableType>Boolean INDATASET<replace>!declaredVariable! :=<moveValueToProperty>!declaredVariable!<movePropertyToControlName>!var1!<moveToProperty>Visible
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:
<find>!currForm!.!var1!.VISIBLE(<replace>!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!
I just tried to implement ur solution and had some problem.
Don't copy and paste the code from the browser into the txt file (using IE and notepad)
Looks like some strange characters will be copied alongside which makes the code not work!!!
Hopefully this helps other persons saving some time :)
great idea of blog for Nav guys....
Never be concerned about if you should have blog or not and never think you have to "satisfy the audience". A blog is a different thing to different people. The more information out there being shared the better.
Its great to see fresh ideas and information.
Keep it up.
Gefeliciteerd! Ik zal je link hier in DE ook verder geven.
Congrats on your first blog post!