Writing C/AL code in a report
The report designed in the previous example retrieved data from a database table and presented the result without extra manipulation. It is as simple as that, when the data the users require does not have to be transformed.
Getting ready
The file name in the source files is REP50020_SalesByCustomerItem.txt
.
How to do it...
Now we will create a report that collects aggregated data into a temporary record to calculate values that cannot be retrieved from a table directly. Aggregated values are computed by C/AL code executed in report triggers.
- Create a report object in NAV Object Designer.
- Declare a global variable
TempValueEntry
ofRecord
type andSubType = Value Entry
. This is a temporary buffer where aggregated report amounts will be stored. Open its properties and setTemporary
toYes
. - Create a data item with the
Customer
table as the data source. - Under the
Customer
data item, add another one and set the data source toItem Ledger Entry
. Open data...