In C/AL we address fields and methods of record variables using the syntax <Record>.<Field> and <Record>.<Method>. To make coding somewhat simpler and the resulting code leaner, with the goal of being easier to read, C/SIDE – uhh NAV DE now we’re on NAV 2013 – has a couple of ways to make implicit references to the record variable.
- using the WITH statement; as the C/SIDE Reference Guide puts it:
If you work continuously with the same record, you can use WITH statements. When you use a WITH statement, you only have to specify the record name once.
- using the Rec variable on any table, bounded page (and form) or codeunit OnRun trigger having the TableNo property set
- using the DataItem variable of the associated DataItem on any report (or dataport)
- using a field as parameter in a record method call, examples being:
As part of the code cleanup between NAV 2013 Beta and RTM, explicit references to record variables, where they could be implicit, have been removed.
The accompanying screen shots show examples of case 1 and 4.
Click on the images to get a full view that’s readable.