NAV2013 Beta to RTM – Some Striking Code Changes #4: Redundant Record References

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.

  1. 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.

  2. using the Rec variable on any table, bounded page (and form) or codeunit OnRun trigger having the TableNo property set
  3. using the DataItem variable of the associated DataItem on any report (or dataport)
  4. using a field as parameter in a record method call, examples being:

    <Record>.SETFILTER(<Field>,…)
    <Record>.
    SETRANGE(<Field>,…)
    <Record>.
    SETCURRENTKEY(<Field>,…)

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.

Leave a Reply

Your email address will not be published. Required fields are marked *