Field list and data binding
The field list shows the data that the template receives. You bind report controls to it by dragging a field or by writing an expression. This page explains where the data comes from and how to use it. It is for implementers and support staff who build templates.
The data source
Each report has one data source, named CurrentDb. It is a stored procedure in the database that answers for the document type you are designing for:
- The procedure is named
prcPrintAR_, then the type name, then_Default, such asprcPrintAR_Bill_Defaultfor an invoice. The document types and their procedures are in Advanced printing data sources. - The procedure receives the ID of the saved document you print. So the preview and the print rely on the saved document, not on what you typed in the window and did not save.
- The procedure returns several sets of data, each about a part of the document (the customer, the currency, the invoice, its items and so on). The first set is a list of the names of the sets, not data. It does not appear in the field list; the program takes the names of the other sets from it.
- The program adds the connection to the database when it opens the template, and removes it when you save or export. So a saved template holds no connection details.
- If the document type has more than one procedure that starts with
prcPrintAR_and the type name, the Change Data Source command appears on the ribbon to switch the source. The command is explained in Ribbon.
The program removed from the designer the command to add a data source to the report and the commands to manage queries. The add-data-source commands of the chart, pivot grid and sparkline tools are not removed, but the report has only its own data source. To create a custom source, see Create a custom data source.
The field list
The Field List panel opens with the designer. What is special in alameen:
- Search bar: It is always shown. You type part of a field name, and the matching fields stay with their parents (the groups that hold them), and the groups with results expand. Example: type
Quantityto reach the quantity field in the invoice lines. - Group names: The program shows the groups under readable names taken from the first set, such as "Bill Items". The names of the fields inside them appear as they are.
Right-click an item in the list to find the command to add a calculated field. It is explained in Calculated fields.
Binding a control to a field
Choose the way that suits you:
| Way | Steps |
|---|---|
| Drag a field | Drag the field from the Field List to a band on the design surface. The designer creates a control bound to it. |
| Write an expression | Select the control, open the Expressions tab in the Properties panel, and type in the property, such as Text, an expression with the field name in square brackets, such as [Quantity], the quantity field of the "Bill Items" table of the Field List. |
| The expression editor | Click the expression button beside the property to open the Expression Editor, which has Fields: double-click a field there to insert it, and the editor writes the path that the band needs. See The expression editor. |
| Edit the bindings | Open the smart tag of the report and click Edit Bindings.... |
The Expressions tab of the Properties panel shows the expression of each property. To bind a control that you already placed, write the field in its expression. The examples in this guide write a field by its column name in brackets and say which table of the Field List holds it; to insert a field, double-click it in the expression editor, or drag it from the Field List.
To format the bound value, such as the number of decimals, use the Format String property, or an alameen function around the field: ToPrice([Price]) (the price field of the "Bill Items" table). See Formatting values.
Report parameters that the program fills
The program puts parameters in the report that carry values from the document window (for example its currency), and you can use them in expressions. It adds them hidden, so the program does not ask for them at preview or print, and it fills them every time the template opens for design, preview or print. Do not add parameters yourself: the program removed the commands to add and edit them.
| Parameter | Meaning |
|---|---|
CurrencyId | The currency of the document. It carries the currency ID, which is what the NumberToText function asks for. |
FirstItemCurrencyId | The currency of the first line of the document. In vouchers only. |
The source of the currency depends on the document type: windows that have a currency box pass the currency chosen in the window, other types pass the default currency, and the packing list gets no parameter. The full list is in How a template gets its data.
Write the parameter in an expression after Parameters.: [Parameters.CurrencyId], and insert it from the list of the expression editor. An example that writes the invoice total in words, in an invoice template:
NumberToText([GrandTotal_ic], [Parameters.CurrencyId])
GrandTotal_ic is the invoice total in the invoice currency, from the "Bill" table of the Field List; GrandTotal is in the base currency.
The function is detailed in alameen functions in expressions.
Related
This page applies to alameen ERP 10, version 10.1.79.764.