Classic Totals

This is a knowledgebase article on totals and what to do when variable names or field names used in totals are changed

In Classic, totals were controlled by the TotalsFields/GroupTotalFields properties and the C/AL function, CREATETOTALS. However, these were removed in NAV2013 and do not exist anymore in standard NAV. Because of this, these properties have been converted to the ForNAV properties: “Total Fields”, “Group Totals Fields”, and “Create Totals” on the Data item, and are maintained in the ForNAV Designer.


When a report is converted or saved by the Designer, ForNAV generates code to emulate totaling in the same way as Classic did (for example, Customer Top 10):

    EVENT ReportForNav@5000::OnTotals@5004(DataItemId : Text; Operation : Text; GroupTotalFieldNo : Integer);
          CurrRecRef : RecordRef;
          NextRecRef : RecordRef;
          CurrKeyRef : KeyRef;
          NextKeyRef : KeyRef;
          FieldIndex : Integer;
          GroupFieldIndex : Integer;
      // Do not change (Autogenerated by Reports ForNAV) - Instead change the Create Totals, Total Fields or Group Total Fields properties on the Data item in the ForNAV designer
      CASE DataItemId OF
        'Customer': WITH Customer DO CASE Operation OF
           'Add': BEGIN
                ReportForNav.AddTotal(DataItemId,0,"Sales (LCY)");
                ReportForNav.AddTotal(DataItemId,1,"Balance (LCY)");
           'Restore': BEGIN
                "Sales (LCY)" := ReportForNav.RestoreTotal(DataItemId,0,GroupTotalFieldNo);
                "Balance (LCY)" := ReportForNav.RestoreTotal(DataItemId,1,GroupTotalFieldNo);

This code should never be changed manually, because it will get overwritten by code generated by the values in the total properties when the report is reconverted or modified by the Designer.

When the total properties have references to variable names or field names that have been renamed in C/SIDE, it is important that you also change the names in the properties, because ForNAV is not able to do this automatically.