Simplifying data access with queries
Structures of NAV client application language allow accessing only one table at a time, there is no C/AL structure that would enable a table join in one statement. This limitation often affects the performance of C/AL code, forcing the developer to use loops on table records where a single query would be sufficient. With a Query object, developers can overcome this limitation and create queries joining several tables.
How to do it...
In this recipe, we will create a query object calculating profit per item, and use the query as a data source for a page.
In the first step, we will add a field to the
Item
table that will specify if an item certificate is required to post an item entry. Open the table 27Item
in table designer and insert the field:Field No.
Field Name
Data Type
50100
Certificate Required
Boolean
Save the modification in the table. Switch to the page designer and open the page 30
Item Card
. Insert the field Certificate Required in...