Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
2 views311 pages

Navision Attain Objects

The document provides an overview of the Navision Attain programming course, focusing on the basic objects within the Client/Server Integrated Development Environment (C/SIDE). It outlines the types of application objects, including tables, forms, reports, dataports, and codeunits, and their respective functionalities. Additionally, it emphasizes the importance of understanding these objects for effective application development and certification as a Navision Attain Consultant in Programming.

Uploaded by

joleb32867
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views311 pages

Navision Attain Objects

The document provides an overview of the Navision Attain programming course, focusing on the basic objects within the Client/Server Integrated Development Environment (C/SIDE). It outlines the types of application objects, including tables, forms, reports, dataports, and codeunits, and their respective functionalities. Additionally, it emphasizes the importance of understanding these objects for effective application development and certification as a Navision Attain Consultant in Programming.

Uploaded by

joleb32867
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 311

Navision Attain Objects

Navision Attain Objects


NOTICE

This material is for informational purposes only. Navision a/s disclaims all
warranties and conditions with regard to use of the material for other
purposes. Navision a/s shall not, at any time, be liable for any special,
direct, indirect or consequential damages, whether in an action of contract,
negligence or other action arising out of or in connection with the use or
performance of the material. This material is subject to change without
notice.

According to Danish copyright legislation it is against the law to reproduce


any part of this material in any form or by any means without the
permission of Navision a/s.

The software described is supplied under license and must be used and
copied in accordance with the enclosed license terms and conditions.

COPYRIGHT NOTICE

Copyright  2002 Navision a/s, Frydenlunds Allé 6, 2950 Vedbaek,


Denmark. All rights reserved.

TRADEMARKS

The trademarks referenced herein and marked with either TM or  are


either trademarks or registered trademarks of Navision a/s or Navision
Development a/s. However, the trademarks Microsoft, Windows, Windows
NT, SQL Server and BackOffice are either registered trademarks or
trademarks of Microsoft Corporation in the United States and/or other
countries.

Any rights not expressly granted herein are reserved.

The trademarks of Navision a/s and Navision Development a/s are listed on
this Web site: http://trademarks.navision.com

The Arial font was used.

Published by Navision a/s.

Published in Denmark 2002.

DocID: AT-310-SST-005-v01.00-W1W1
TABLE OF CONTENTS

CHAPTER 1.

INTRODUCTION 1-1

1.1 About the Course 1-2

1.2 The Basic Objects in Navision Attain 1-3

1.3 C/SIDE Fundamentals 1-4

CHAPTER 2.

BASIC TABLES 2-1

2.1 What Is a Table? 2-2

2.2 Table and Field Properties 2-4

2.3 Creating Tables 2-7

2.4 What Are Keys? 2-14

2.5 Setting Relationships Between Tables 2-20

2.6 Special Table Fields 2-30

2.7 Modifying Some Properties 2-45

2.8 Types of Tables and Their Characteristics 2-


51

2.9 Answers to the Questions 2-65

2.10 Chapter Test 2-73

CHAPTER 3.

BASIC FORMS 3-1

3.1 What Are Forms? 3-2


TABLE OF CONTENTS

3.2 Starting with a Blank Form 3-5

3.3 Other Useful Controls 3-15

3.4 Using the Form Wizard 3-27

3.5 Creating Buttons 3-35

3.6 Creating Subforms 3-43

3.7 Form Types and Characteristics 3-49

3.8 Standard Navigation 3-56

3.9 Answers to the Questions 3-58

3.10 Chapter Test 3-69

CHAPTER 4.

BASIC REPORTS 4-1

4.1 Reports 4-2

4.2 The Report Designers 4-7

4.3 How Sections Work 4-17

4.4 Some Useful Properties 4-23

4.5 Grouping Within a Report 4-26

4.6 Totaling in a Report 4-32

4.7 Adding Some Advanced Features 4-36

4.8 Types of Reports 4-43

4.9 Creating a Basic Report 4-46

4.10 Answers to the Questions 4-47

4.11 Chapter Review 4-57

CHAPTER 5.
BASIC DATAPORTS 5-1

5.1 Dataport Fundamentals 5-2

5.2 Designing Dataports 5-9

5.3 Sample Dataports 5-16

5.4 Chapter Review 5-32

CHAPTER 6.

BASIC CODEUNITS 6-1

6.1 A C/SIDE Codeunit 6-2

6.2 Creating Codeunits 6-4

6.3 Using Codeunits 6-12

6.4 Chapter Review 6-17

Appendix A.

QUESTIONS I

Appendix B.

ANSWERS XV
PREFACE

This course is one of four modules in the Navision Attain® Programming


course, which is part of the Navision Attain Solution Development training
material. The course is intended to be used as self-paced study material
and can be used separately or in connection with the other three modules
in the course.

When you have completed all four modules in the Navision Attain
Programming course, you can take the Navision Attain Programming test to
be certified as a Navision Attain Consultant in Programming.

The following diagram shows all the courses in the Navision Attain®
training curriculum with subject areas shown in gray:
Chapter 1.

Introduction

In this chapter, we introduce you to the basic


objects that are found in Navision Attain.

This chapter contains the following sections:

About the Course

The Basic Objects in Navision Attain

C/SIDE Fundamentals
1-2 Navision Attain Objects

1.1 ABOUT THE COURSE

Who Is This Course Designed for?

This course is designed for anyone who would like to understand the basic
objects found in the Navision Attain Client/Server Integrated Development
Environment (C/SIDE). We suggest this course to anyone who will be using
C/SIDE.

What Will You Get Out of This Course?

This course will give you a basic understanding of how to create and use
the basic objects found in C/SIDE. You will learn about all the different
object designers and experiment with just a few of the dozens of properties
for each object. The following topics will be presented in this course:

Chapter 1: The introduction – this section

Chapter 2: Basic Tables

Chapter 3: Basic Forms

Chapter 4: Basic Reports

Chapter 5: Basic Dataports

Chapter 6: Basic Codeunits

Remember that this course is a self-study. Take as much time as you need
to complete each exercise. Read the material as thoroughly as you can. If
you need to go back and review a section, take time to do that. You must
understand this material in order to be certified.
Introduction 1-3

1.2 THE BASIC OBJECTS IN NAVISION ATTAIN

There are five basic objects in C/SIDE. The first object that you will learn
about in this course is the table object. A table is used to describe how data
will be stored in the database and how it will be retrieved. Understanding
tables is the key to using all of the other objects that you will learn about.

The second type of object that you learn about is the form object. A form is
used to display data to the user in a familiar and useful way. Most forms
allow the user to add records to a table, view and modify records as well.

Then, you will learn about the report object. Reports allow the user to
summarize and print out detail information using the filters and sorting that
he or she chooses. You will learn how to design and then create reports
using the report designer in C/SIDE.

The fourth object that you will learn to use is the dataport object. Dataports
allow you to export or import table data. The dataport and report objects
share an underlying architecture so you will be able to apply what you
learned about reports here.

The last type of object that you need to understand is the codeunit object.
Codeunits allow you, the developer, to organize and group the code that
you write. This is the only object mentioned so far that you might think does
not have anything to do with tables, but it actually does.

Is Navision Attain Object Oriented?

C/SIDE is not object oriented but object-based. This is an important


distinction. In an object oriented language or environment, the developer
can create new types of objects based on the ones already in the system.
In C/SIDE, you have five types of application objects and that is all. You
can create and use tables, forms, reports, dataports and codeunits, but
nothing else.

This may seem like a huge limitation, but be aware that with every
limitation, there is an increase in freedom. By limiting you to these five
objects, C/SIDE can be streamlined to work faster and more efficiently. It
also frees you up in your design work. You know exactly what you have to
work with. The greatest benefit from this limitation is stability. It is actually
somewhat difficult to create a severe bug in C/SIDE and this is good for
everyone.
1-4 Navision Attain Objects

1.3 C/SIDE FUNDAMENTALS

A C/SIDE (Client/Server Integrated Development Environment) application


is composed from five types of application objects. Each type of application
object is created using a specific tool called a designer. The application
objects you create using these designers are all based on some general
concepts. A fundamental knowledge of these concepts speeds up the
C/SIDE application development process. This section introduces you to
the C/SIDE user interface and presents the general concepts that underlie
C/SIDE application objects –

• The C/SIDE User Interface

• What Is a C/SIDE Application?

• The Physical and the Logical Database

The C/SIDE User Interface

This section introduces you to the user interface in C/SIDE. If you have not
already installed C/SIDE, refer to the installation manual. If you have
already installed C/SIDE, the installation program has created a new group
that contains all the icons you need to work with in C/SIDE. When the
Integrated Development Environment (IDE) is running, your screen will look
like this:
Title Bar

Menu Bar

Tool Bar
(A)

Work
Area

Status Bar
The user interface gives you access to a number of tools and functions.
Introduction 1-5

Some parts of the user interface, also provide information about the current
state of the system. The table below explains when to use the most
important parts of the C/SIDE user interface.

To... Use the...

get information about the name and path of the current title bar
database

access functions on drop-down menus menu bar

access the most commonly used functions quickly toolbar (A)

work with the application design tools work area (B)

see basic status information about your system (such as status bar
the current date and your user ID)

(A) Depending on the task you are working on, the system automatically changes
the icons.

(B) This is also where the user interacts with your applications.

Designing Application Objects

Any application designed in C/SIDE is based on five different types of


application objects:

Tables are the fundamental objects that store the actual data; you need
other application objects to insert, modify, delete or show data from tables.
You will typically use a form to enter or retrieve data from the database and
use a report to print data.

Note

All the application objects are identified by an ID number. There are,


however, restrictions about which numbers you should use when you
create your own application objects.

The main tool used for developing applications in C/SIDE is the Object
1-6 Navision Attain Objects

Designer (select Tools, Object Designer). This is the tool you use to view
and design tables, forms, reports, dataports and codeunits. In the Object
Designer you choose the type of application object you want to work on.
From the Object Designer you can run an application object or start an
application object designer to modify the design of an existing application
object or create a new application object. The following picture shows how
to use the Object Designer in more detail.
This is where you
access the
designers for
different objects.
You simply choose
the type of object
you want to work
on here.

Create a new object

Change the design of the current object


Run the current object
The table below lists the tools you can access via the Object Designer and
when you should use them.

Use the... When working on ...

Table Designer Tables

Form Designer Forms

Report Designer Reports

Dataport Designer Dataports

C/AL editor Codeunits

As you can see, there is a specific designer for each type of application
object. When you create or modify an application, you can work on any
number of application objects at the same time, and each application object
is shown in its own designer. For example, if you work on three new forms
at the same time, then each form will be displayed in its own form designer.
The only designer that you cannot create more than one copy of is the
Object Designer. You will learn more about how to use each of these
designers as you read the following parts of this book.
Introduction 1-7

What Is a C/SIDE Application?

The C/SIDE Integrated Development Environment (IDE) is specially


designed for creating accounting and business management applications.
Any C/SIDE application consists of the same objects as a C/SIDE
database. The difference between the term database and the term
application is that when we speak about a database, we mean simply a
collection of application objects, whereas when we speak about an
application, we mean a set of application objects tied together to form a
coherent whole.

General C/SIDE Concepts

You have already learned that there are five different types of application
objects in C/SIDE. All five types are based on some general concepts.
Some of these concepts are restricted to one type of application object
while others apply to several types. When you understand these
fundamental concepts, you have a good foundation for creating your own
applications. The table below summarizes how the application objects are
related to these general concepts and explains what each type of
application object is used for.

Application What is it used for? Which


Object concepts is it
Type based on?

Table A table is used for storing the actual data. Properties,


Typically a business application will have Fields, Keys,
a Customer table that stores information C/AL, Triggers
such as name, address, phone number
and contact person for each of your
customers.

Form A form is used to access the information Properties,


in your tables. Forms are used both when C/AL,
you enter new information and when you Controls,
view existing information. Triggers

Report A report is used to present data that Properties,


contains summary information. For C/AL, Controls,
example, you will use a report to print a DataItems,
list of customers. Sections,
RequestForm,
Triggers
1-8 Navision Attain Objects

Application What is it used for? Which


Object concepts is it
Type based on?

Dataport A dataport is used to import and export Properties,


information to and from other programs (a C/AL,
comma-separated file from a DataItems,
spreadsheet, for example). RequestForm,
Triggers

Codeunit A codeunit contains user-defined C/AL, Triggers


functions written in C/AL code. These
functions can be used from the other
objects in your application. This minimizes
the size of the application because the
same code can be reused over and over
again.

The terms in the third column have the following descriptions:

Properties: Properties control the appearance and behavior of application


objects and all subobjects. Properties are used to control the appearance
of data, specify default values, specify colors and define relationships.

C/AL: C/AL is the language used for writing functions in C/SIDE. In the
table above, "C/AL" refers to functions written in this language.

Triggers: When specific things happen to the application objects, the


system automatically activates a trigger. Inside a trigger, you can add your
own C/AL code if you want to modify the default behavior of the application
object or extend its functionality.

Keys: A key defines the order in which data are stored in your tables. You
can speed up searches in your tables by defining several keys that sort
your information in different ways.

Fields: A field is the smallest unit of information in your database. A field


typically stores information such as a name or a number.

Controls: Controls are objects on a form or report that display data,


perform actions or decorate the form. Typical examples are command
buttons and text labels.

Request Form: A request form is a form that is used in a report. Before a


report is run, a request form appears to let the user specify filters and
Introduction 1-9

options for the report.

Data Items: A data item is a building block you use for defining a model of
your data when you create a report. By using a hierarchy of data items, you
define which data your report should include. A data item represents a
table and when you run a report, the system cycles through the records in
the associated table. A data item can have one or more sections.

Sections: A section is a substructure of a data item. A section is where you


place controls to display information. You will typically use sections defining
the body, header, and footer in your report.

The Physical and the Logical Database

The previous section described the general concepts underlying all five
types of application objects in C/SIDE. This section presents another view
of C/SIDE applications. In this view, we are concerned only with how the
information in your application is structured.

As a typical database user, you are not concerned with where each piece
of data is stored on the hard disk or what its size is; you just want to be
sure that when you refer to a name, for example, the correct value is
returned. This is why the C/SIDE database system provides you with a
conceptual representation of data that does not include too many details of
how the data is stored. An abstract data model is used for this conceptual
representation. This data model uses logical concepts (such as objects,
their properties and their relations) that are easier to understand.

This leads us to distinguish between the logical and the physical database.
When we speak about the logical database, we are concerned only with the
structure of the data and the relationships between different bits of
information. That is, we do not deal with how these structures and relations
are implemented. When we speak about the physical database, we deal
only with how the structures in the logical database and the search paths
between them are implemented.

In this course, the term database should be interpreted to mean the logical
database unless otherwise noted.

What the user sees as a coherent set of information in the C/SIDE


database system can be stored in several physical disk files but this is
transparent to the user. The figure below illustrates how one logical
database can be physically stored on three hard disks but still comprise a
single (logical) database.
1-10 Navision Attain Objects

The Logical Structures in Your Database

Access to the data is made possible by a well-defined logical organization


composed of:

Fields: A field is the smallest logical structure used in the C/SIDE


database. A field is used to hold a single bit of information, such as a
name, "Joe," or an amount, "2,352.00." Any particular field can hold
information of only one specific type. (The C/SIDE database system
distinguishes between 10 different types of information.) Fields are
assembled into a structure called a record. On its own, a field is not very
useful as it can hold only a limited amount of information. By assembling
these small bits of information into records, we get a much more flexible
"information-holder" that is also better organized because it keeps together
fields that belong together.

Records: A record is a logical structure assembled from an arbitrary


number of fields. It is used to store a single entry in the database. The
fields in a record are used to store information about important properties of
the entry. Records are organized in tables.

Tables: A table can be thought of as an N times M matrix. Each of the N


rows describes a record and each of the M columns describes a field in the
record. Tables are organized in companies.

Companies: A company is the largest logical structure used in a C/SIDE


database. A company may be considered as a subdatabase; its primary
use is to separate and group large portions of data in a database. A
company can contain private tables as well as tables shared with other
companies.

Companies are the Database


largest logical Company
structure in a C/SIDE
database.
Table
Record
Field
Chapter 2.

Basic Tables

Tables are the fundamental objects in any


database. This is true no matter what kind of data
you need to store. When you create a new
database, you begin by building the tables. Later
on, you create forms and reports in order to
access and view the data in the tables.

This chapter explains how to design appropriate


tables to store your data. The exercises in this
chapter will reinforce the knowledge you will gain
in this part of the course.

This chapter contains the following sections:

What Is a Table?

Table and Field Properties

Creating Tables

What Are Keys?

Setting Relationships Between Tables

Special Table Fields

Modifying Some Properties

Types of Tables and Their Characteristics

Answers to the Questions

Chapter Test
2-2 Navision Attain Objects

2.1 WHAT IS A TABLE?

The records in the C/SIDE database are stored in tables. A C/SIDE table
may be visualized as a two-dimensional matrix consisting of columns and
rows. The figure below shows a table with nine rows and eight columns.
Each row is a record, and each column is a field.

Columns: Fields

Rows: Records

A table consists of two parts – the table data and a table description. The
table data is the part users often think of as comprising the database
because it contains the actual records with their data fields. The layout and
properties of those fields however, are specified by the table description.

The table description is not directly visible to the user. The following figure
illustrates how the table data and the table description together form a
table:

Table
This is the
- Properties
table
- Triggers description

- Keys

Table Data

When you design a table, you assign it a number of characteristics such as


a name, an ID number and the fields it contains. You also assign a number
Basic Tables 2-3

of characteristics (such as name, ID number, data type and initial value) to


each field. When you design a new table, you also specify which keys you
want the system to maintain. All these characteristics are stored in the table
description when you save your table design.

The following figure illustrates that a table description contains properties,


triggers, fields and keys and shows how these are related:

Table Description

Table Properties

Triggers

Fields

Properties

Triggers

Keys

Properties

The table description contains some properties that are related to the table
while others are related to the fields in the table. Still other properties are
related to the keys in the table. You can also see from the figure that
triggers are defined both for the table and for the fields in the table. The
following sections will describe these terms in further detail.
2-4 Navision Attain Objects

2.2 TABLE AND FIELD PROPERTIES

This section describes how you can use properties in your table design. It
discusses how to modify and use table and field properties.

Viewing and Modifying Table Properties

A table in C/SIDE has a number of properties that describe the behavior of


the table in your environment. When you create a table, C/SIDE
automatically defines a number of default values for these properties.
Depending on the purpose of the table and how it is related to other
application objects, you may want to change these default values.

Refer to the online Reference Guide for additional information about


properties.

To view or modify table properties:

1 Click Tools, Object Designer.

2 In the Object Designer window, click Table to get a list of the tables.

3 Select a table and click Design. C/SIDE will display the table in the
Table Designer.

4 Place the cursor on an empty line in the Table Designer or click Edit,
Select Object. (If you place the cursor on a line defining one of the
fields in the table, you will get the properties for the field instead of
those for the table.)

5 Click View, Properties. C/SIDE will display the Properties window.

6 If you want to modify the setting of a property, simply enter the new
value in the Properties window. When you have entered the new
value, update the property by either pressing ENTER or simply moving
the cursor away from the field.

7 To get Help for a property, point at it in the Properties window and


press F1.

Example

Use the steps above to look at the LookupFormID property of the


Customer table (18). This property tells C/SIDE which form should be used
to lookup values in the Customer table. The value of the property is the
Basic Tables 2-5

Customer List form.

Viewing and Modifying Field Properties

Just like tables, all fields in C/SIDE have a number of properties that
describe their behavior. When you create a field, C/SIDE automatically
suggests a number of default values for these properties. Depending on the
purpose of the field, you will sometimes want to change these default
values.

Refer to the online C/SIDE Reference Guide for additional information


about the above properties.

To view or modify field properties:

1 Click Tools, Object Designer.

2 In the Object Designer window, click Table to get a list of the tables.

3 Select a table and click Design. C/SIDE will display the table in the
Table Designer.

4 Place the cursor on the line in the Table Designer that defines the field
for which you want to access the properties.

5 Click View, Properties. C/SIDE will display the Properties window.

6 If you want to modify the setting of a property, simply enter the new
value in the Properties window. When you have entered the new
value, update the property by either pressing ENTER or simply moving
the cursor away from the field.

7 To get Help for a property, point at it in the Properties window and


press F1.

Example

Use the steps above to look at the NotBlank property of the No. field in the
Customer table (18). This property keeps the user from leaving the No.
field blank. It is used on most primary key fields (you will learn about these
later).
2-6 Navision Attain Objects

Exercise 2.2.1 Investigating existing tables

In this exercise, you will be asked questions about tables that already exist
in the base application. Answer each question as completely as you can.

What is the option string for the Reserve field in the Customer table?

What is the difference between the calculation formulas of the Balance


field and the Balance At Date field in the G/L Account table?

What type of field is the Date Filter field in the G/L Account table?

What is the value of the TableRelation property of the Currency Code field
in the Customer table?
Basic Tables 2-7

2.3 CREATING TABLES

Creating a Table

When you first create a table, it will not contain any data. When you create
the table you have to decide which types of information you want to store in
it.

To create a table, follow this procedure:

1 Click Tools, Object Designer. The Object Designer window appears.

2 In the Object Designer window, click Table.

3 Click New. The Table Designer window appears:

In the Table Designer, for each field you add to the table, you enter the field
number, name, data type and, optionally, a length and a description. The
following subsections describe how to do this.

Adding Fields to Your Table

Designing a field means assigning it a number of characteristics. These


characteristics depend on what you intend the field to be used for.

After you have added fields to a table in the Table Designer, you must save
the table before you can add any records. Once you have saved a table, it
will appear in the list of tables in the Object Designer.

All the tables and fields you create have two forms of identification:

• A unique identification number (integer). When you access your


database using either C/SIDE or C/FRONT, this number uniquely
identifies all tables and fields.
2-8 Navision Attain Objects

• A name (an alphanumeric string) serving as a label (such as


CUSTOMER or CITY). This name appears on the screen when you run
the table and should be meaningful and easily understood. This name
is secondary information and can be changed at any time.

Choosing Data Types

When you have selected an identification number and name for a field, you
have to select an appropriate data type. You can use 11 different types of
fields in the C/SIDE database system. Each type is designed to hold a
specific kind of information, such as text, numbers, dates and so on.

Fields in a record can be of the following types:

Data Type Description Size

Option Denotes an integer in the range -2,147,483,647 to 4 bytes


2,147,483,647. An option field is defined with an
option string, which is a comma-separated list of
strings representing each valid value of the field.
This string is used when a field of type Option is
formatted and its value is converted into a string.
An example: The option field Color is defined with
the option string "Red,Green,Blue". Valid values
of the field are then 0, 1 and 2, with 0
representing "Red" and so on. When the "Color"
field is formatted, 0 is converted into the string
"Red", 1 into "Green", and 2 into "Blue".

The size of the corresponding SQL data type,


INTEGER, is 4 bytes. (A)(B)

integer Denotes an integer between -2,147,483,647 and 4 bytes


2,147,483,647.

The size of the corresponding SQL data type,


INTEGER, is 4 bytes. (A)(B)

decimal A decimal number between -10 63 and 10 63 . The 12 bytes


exponent ranges from -63 to +63. Decimal
numbers are held in memory with 18 significant
digits. The representation of a decimal number is
a Binary Coded Decimal (BCD).

The size of the corresponding SQL data type,


DECIMAL(38,20), is 17 bytes. (A)(B)
Basic Tables 2-9

Data Type Description Size

Text Any alphanumeric string. The field must be Maximum


defined to be between 1 and 250 characters. The string
space used by a text field equals the maximum length + 1
length of the text plus one byte. This extra byte is byte (see
used to hold the length of the string. An empty note
text string has the length zero. below).

The size of the corresponding SQL data type,


VARCHAR, is 1 byte per character in the field’s
value. (A)(B)

code An alphanumeric string, which is right justified if Maximum


the contents are numbers only. If letters or blanks string
occur among the numbers, the contents are left length + 2
justified. All letters are converted to uppercase bytes (see
upon entry. The field must be defined to be note
between 1 and 250 characters. below).

The space used by a code field equals the


maximum length of the text plus two bytes. The
first of the extra bytes holds information about the
length of the string, and the second byte stores
alignment information.

In the Microsoft SQL Server Option for Navision


Attain, code fields work in a different way. You
can use the SQL Data Type property to indicate
whether code fields can contain integers or text
strings. Refer to the online C/SIDE Reference
Guide for information about the SQL Data Type
property.

The size of the corresponding SQL data type,


VARCHAR, is 1 byte per character in the field’s
value. (A)(B)

date A date value in the range from January 1, 0 to 4 bytes


December 31, 9999. An undefined date is
expressed as 0. All dates have a corresponding
closing date. The system regards the closing date
for a given date as a period that follows the given
date but comes before the next normal date; that
is, a closing date is sorted immediately after the
corresponding normal date but before the next
2-10 Navision Attain Objects

Data Type Description Size

normal date.

In the Microsoft SQL Server Option, dates cannot


be before 01/01/1754. The size of the
corresponding SQL data type, DATETIME, is 8
bytes. (A)(B)

Time Any time in the range 00:00:00 to 23:59:59.999. A A time


time field contains 1 plus the number of field is
milliseconds since 00:00:00 o'clock, or 0 (zero), stored as
an undefined time. A time value is calculated in an integer
the following way: Time = 1 + (number of (four
milliseconds since 00:00:00). bytes).

The size of the corresponding SQL data type,


DATETIME, is 8 bytes. (A)(B)

boolean Assumes the values TRUE or FALSE. When 4 bytes


formatted, a boolean field is shown as "Yes" or
"No".

The size of the corresponding SQL data type,


TINYINT, is 1 byte. (A)(B)

binary Contains binary data. The binary data is stored in Maximum


the record. length is
250 bytes
The size of the corresponding SQL data type,
(see note
VARBINARY, is the number of bytes in the field’s
below).
value. (A)(B)

BLOB Binary Large Object. Used to store bitmaps and 8 bytes in


memos. Notice that the BLOB isn’t stored in the the record
record, but in the BLOB area of the table. + size of
BLOB
The size of the corresponding SQL data type,
data.
IMAGE, is the number of bytes in the field’s value.
(max. 2
(A)(B)
GB)

dateformula To be used when this field will contain a date 30 bytes


formula. This data type is multilanguage-enabled.

(A) The calculation of the size of a specific SQL Server record requires
more than simply summing the sizes of the field values. Refer to Microsoft’s
SQL Server documentation for further information.
Basic Tables 2-11

(B) This is the SQL server data type that Navision Attain uses when it
creates the Navision Attain data type. For further information, see the
manual Application Designer’s Guide.

Note

In Navision Server, data is stored with a four byte alignment because of


performance considerations. The sizes of text, code and binary fields (that
can have variable lengths) are rounded up to the nearest value that is a
multiple of four. This means that, for example, a text string of 10 characters
will occupy 12 bytes.

Exercise 2.3.1 Creating a Simple Table

In this exercise, you will create a simple table.

1 From the Tool menu, choose Object Designer.

2 In the Object Designer, click the Table button.

3 Click New. C/SIDE will display the Table Designer.

4 Enter the Field Numbers, Field Names, Data Types and Lengths (if
applicable) for each field:

No. Name Type/ Length

1 Model Code 20

2 Serial No. Integer

5 Description Text50

7 Transmission Option (Automatic,4-Speed, 5-Speed)

10 List Price Decimal

15 Date of Mfg Date

5 Edit the Field Properties, if needed.


2-12 Navision Attain Objects

6 Save the new table by closing the Designer window, click Yes at the
Save dialog, and then enter the Table ID Number (91200) and Table
Name (Vehicle) in the Save As dialog.

Exercise 2.3.2 Adding Data

In this exercise, you will add data to the table created in the previous
exercise.

1 From the Tool menu, choose Object Designer.

2 In the Object Designer, click the Table button.

3 Find table 91200 and select it.

4 Click the Run button.

You are now viewing the data in the new Vehicle table. Notice that it is
currently empty. The form you have open was auto-created by the Client
application when you chose to run the table. This is a basic tabular form.

Now, you can enter some test data for your table and begin testing the
functionality.

5 Attempt (notice the word attempt) to put in the following records.

Model Serial Description Transmission List Date of


No. Price Mfg.

FORD 5000 Red, Automatic 18,000 01/15/00


Mustang

FORD 2000 Blue, F150 5-Speed 26,000 01/15/00

TOYOTA 1000 Gold, Automatic 23,000 02/01/01


Camry

FORD 3000 Black, Automatic 30,000 01/15/00


Explorer
Basic Tables 2-13

Model Serial Description Transmission List Date of


No. Price Mfg.

TOYOTA 3000 Black, 5-Speed 20,000 12/15/99


Takoma

TOYOTA 2000 Gray, Automatic 22,000 01/15/00


Camry

6 Answer the following questions:

What problem did you encounter?

Why can’t you enter the second record above?

7 Close the form and let’s fix the problem you have discovered. This is
done in the next exercise.
2-14 Navision Attain Objects

2.4 WHAT ARE KEYS?

A table description contains a list of keys. A key is a sequence of one or


more field IDs from the table. Up to 40 keys can be associated to a table.
The first key in the list is the primary key.

The database keeps track of each record by means of the record's primary
key. You can consider the primary key of a record as the name of the
record. The name of each record in a particular table for a particular
company must be unique. This name is how the DBMS retrieves and
updates records.

The primary key is composed of up to 20 fields in a record. The


combination of values in fields in the primary key makes it possible for the
DBMS to perform a unique identification of each record. The primary key
determines the logical order in which records are stored regardless of their
physical placement on disk.

Logically, the records are stored sequentially in ascending order, sorted


according to the primary key. Before adding a new record to a table, the
DBMS checks that the information in primary key fields in the record is
unique and only then inserts the record into its correct logical position.
Because the records are sorted "on the fly," the database will always be
structurally correct. This allows fast data manipulation and retrieval.

The primary key is always active; the DBMS keeps the table sorted in
primary key order and rejects records with duplicate values in primary key
fields. Therefore, the values in the primary key must always be unique. Be
aware that it is not the value in each field in the primary key that must be
unique, but rather the combination of values in all the fields comprising the
primary key.

The C/SIDE database system does not support tables without keys.

Exercise 2.4.1 Setting the Primary Key

Changing the primary key of a table:

1 In the Object Designer, click the Table button.

2 Find table 91200 and select it.

3 Click the Design button. This opens the Table Designer window for the
Vehicle table.
Basic Tables 2-15

4 On the main menu, click View, Keys. This displays the Key Designer
window. Notice that the primary key contains only one field - Model.
This means that you cannot enter two records with the same Model.
For your example this is not a good choice for the primary key. If you
were to include Serial No. in the primary key, then you could enter the
same model many times as long as the Serial No. field is different for
each.

5 Click in the Key column on the first line in the Key Designer window.

6 Click the Assist-Edit button. Here you can select more fields to be part
of this key.

7 Add the Serial No. field to this list and click OK.

8 Exit the Table Designer window and save and compile the table. The
primary key has been changed.

9 Finish entering the data from step 1. Notice that the records are sorted
in the order of the primary key fields (Model and then Serial No.).
2-16 Navision Attain Objects

Secondary Keys

We have already mentioned that up to 40 keys can be associated to a table


and that the first is the primary key. All other keys are secondary keys and
optional. Secondary keys are used to view records in an order different
from the one in which they are sorted according to the primary key fields.

Note

The number of fields in the primary key together with all the fields in each
secondary key must not exceed 20.

In other words, each secondary key can contain up to 20 unique fields.


However, these 20 unique fields must also include all the fields from the
primary key. The primary key fields that are not mentioned specifically in
the secondary key are added to the end of the key by the DBMS.

This means that if your primary key includes four distinct fields, then a
secondary key can include these four fields and at most 16 others.
Correspondingly, if your primary key consists of 20 distinct fields, then your
secondary keys must consist only of combinations of these fields.

When you define a secondary key and mark it as active, the system will
automatically maintain an index reflecting the sorting order defined by the
key. Several secondary keys may be active at the same time.

A secondary key can be changed into an inactive key. This means that the
DBMS does not use time during updates to maintain its index. Furthermore,
an inactive key doesn’t occupy database space.

Inactive keys can be reactivated; this process may consume some time
depending on the size of the table because the DBMS has to scan the
entire table to rebuild the index.

The fields comprising the secondary keys are not guaranteed to contain
unique data; the DBMS does not reject records with duplicate data in
secondary key fields. If two or more records contain identical information in
the secondary key, the DBMS will use the primary key for the table to solve
this conflict.
Basic Tables 2-17

Exercise 2.4.2 Creating Secondary Keys

For some of your users, the date of manufacture and transmission is more
important. Those users would like to be able to change the order of the
records on the form to Date of Mfg., Transmission. To accomplish this you
need to set up a secondary key.

1 In the Object Designer, click the Table button.

2 Find table 91200 and select it.

3 Click the Design button. This opens the Table Designer window for
the Vehicle table.

4 On the main menu, click View, Keys. This displays the Key Designer
window.

5 Click on a blank line (this should be the second line).

6 Click the Assist-Edit button. Here you can select the fields to be part of
this key.

7 Select the Date of Mfg. field first and then the Transmission field.
The order of the fields is important. In the order described, the records
will be sorted by Date of Mfg. first and then by Transmission (if some
of the dates are the same).

8 Exit the Table Designer window and save and compile the table. The
secondary key has been created.
2-18 Navision Attain Objects

Exercise 2.4.3 Using Secondary Keys

In this exercise, you will use the secondary key created in exercise 5.2.4.

1 From the Tools menu, choose Object Designer.

2 In the Object Designer, click the Table button.

3 Find table 91200 and select it.

4 Click the Run button.

5 You are now viewing the data in the new Vehicle table. Notice that the
data that you previously entered is still there. You may also notice that
the records are still sorted in primary key order.

To change the sorting of the records in the form:

1 Click the Sort button on the Tool Bar. This displays the Sort window.

2 Choose the new key you created (the second key in the list) and click
OK. The records should immediately resort themselves using the new
key.

Answer the following questions:


Basic Tables 2-19

Look at the records that have a Date of Mfg. of 01/15/00. What order are
these records in since they have the same date?

Look at the records that have the same Date of Mfg. and the same
Transmission. What order are these records in?

What does this tell you about secondary keys?


2-20 Navision Attain Objects

2.5 SETTING RELATIONSHIPS BETWEEN TABLES

If your database contains tables with related data you can define a
relationship between them. You relate tables by specifying one or more
fields that contain the same value in related records. These matching fields
often have the same name in each table. You can use relationships to:

• Validate data entries.

• Perform Lookup in other tables.

• Automatically propagate changes from one table to other tables.

Table Relations and the TableRelation Property

Table relations are defined using the TableRelation property. This property
is very flexible and allows you to define both simple and advanced table
relations. A typical simple table relation consists of just a table ID and an
optional field ID, while advanced table relations are typically prefixed with a
conditional statement and include filters.

When you create a table relation, you are specifying which field to lookup in
another table. If the optional field ID is left blank, it is the first field in the
primary key that the relation is made to. To make a relation to the second
or third field in a primary key, you must specify the field ID.

Note

The field ID specified in the TableRelation property must be in the primary


key of the table specified by the table ID in the property.

If the field specified is not the first field in the primary key, the other fields
that are before it in the key must be filtered to one value. This is not a true
requirement of the system, but only makes sense in a real application. The
user must not be confused when presented with choices.
Basic Tables 2-21

Exercise 2.5.1 Simple Table with Table Relations

Create a table with the following fields. The table will hold information about
the sale of an item. Do not be concerned here with why you would need
this table. It is not of any particular use, except in this exercise.

Primary Key Field No. Field Name Data Type

Yes 1 Line No. Integer

3 Salesperson Code Code 10

6 Item No. Code 20

9 Amount Decimal

Save the table with the name Sales Transaction and the ID 91300.

Now that the basic table has been created, add two simple table relations.

1 Open the Sales Transaction table (91300) in the Object Designer.

2 Select the Salesperson Code field. This field will hold values from the
Salesperson/Purchaser table. The user may lookup a value from the
table or type in a value, but it must exist in the
Salesperson/Purchaser table. Due to these requirements, you need
a table relation on this field.

3 Open the Properties window for the Salesperson Code field.

4 Select the TableRelation property for the Salesperson Code field and
click the assist-edit button.

5 In the Table Relation window, enter 13, the ID of the


Salesperson/Purchaser table, in the Table field. You can also use
the lookup button to select the table or enter the name of the table.
2-22 Navision Attain Objects

6 Click OK to save your changes to the property.

7 Close, save and compile the table.

Now, you need to test your table relation. The following steps will
demonstrate how powerful table relations are. Keep in mind that the lookup
buttons on a field that has a table relation open the default lookup form for
the related table. Without a form for the table, the lookup button does not
work. In this example, there are already forms defined for the
Salesperson/Purchaser table.

1 In the Object Designer, run table 91300 (Sales Transaction).

2 In the Line No. field of the first empty line, enter 10000.

3 Click the lookup button in the Salesperson Code field to retrieve a


value from the Salesperson/Purchaser table.

4 Select AH (Alice Hart) and click OK. Notice that the Salesperson
Code field now has the value AH. Because the TableRelation was
only set up to the table (not to any particular field), the lookup returns
the value from the first primary key field. Because the
Salesperson/Purchaser table only has one field in the primary key,
there was no need to specify a field (only primary key fields can be
chosen in a TableRelation).

5 Delete the value AH from the Salesperson Code field and type just
an “a”. What happens when you press Enter?

6 Delete the value again and type in XY. What happens when you press
Enter?
Basic Tables 2-23

7 Close the table.

Exercise 2.5.2 Renaming Records

Changing the primary key values of a record in a table changes the name
of the record. This is called this renaming a record. In this exercise, you will
see the results of renaming a record that has other records related to it via
a table relation.

1 In the Object Designer, run table 13 (Salesperson/Purchaser).

2 Select a blank line and add yourself as a salesperson. Enter your


initials in the Code field and your name in the Name field.

3 Close table 13.

4 Run table 91300 (Sales Transaction).


2-24 Navision Attain Objects

5 Enter the following lines (XXX represents your initials):

Line No. Salesperson Item No. Amount


Code

30000 XXX 70000 123.56

40000 AH 70000 234.97

50000 XXX 70010 90.99

6 Close table 91300.

7 Run table 13 (Salesperson/Purchaser).

8 Select the line that you added earlier (the record with your initials and
name) and change the primary key value. Instead of your initials,
change it to the first three letters of your last name.

9 Click Yes when it asks, do you want to rename the record.

10 How long did it take to change that value? Did it take longer than you
expected?

11 Run table 91300 (Sales Transaction) and check the data it contains.
Did any of the records here change? Why?

8 You may have noticed that you did not put a table relation on the Item
No. field.

You must now relate the Item No. field to the Item table with a simple table
relation.
Basic Tables 2-25

Exercise 2.5.3 Filtered Table Relations

In this exercise, you add filters to one of the table relations that you created
in the previous exercises.

You may have noticed that table 13 (Salesperson/Purchaser) not only


holds salespeople but also purchasers. In your table, you do not want the
user to select purchasers, only salespeople, so you will add a filter to the
table relation. Salespeople have commission rates, while purchasers do
not. This will allow us to distinguish between the two.

1 Open table 91300 in the Table Designer.

2 Select the Salesperson Code field. This is the field that you want to
change.

3 Open the Properties window for this field and select the
TableRelation property.

4 Click the assist-edit button to open the Table Relation window. Notice
that only the Table field is filled in. You need to also give the relation a
table filter.

5 Select the Table Filter field and click the assist-edit button to bring up
the Table Filter window. In this window you can specify filters on as
many fields in the related table as you need to. For each field you add
to the list, you can filter it in three ways – by a constant value, using a
filter expression or by a field in the current table (91300). In this case
you will use a filter expression.

6 In the first column, lookup and select the Commission % field. This
stores the commission rate for the salesperson.

7 In the second column, click the dropdown button and select Filter. You
must choose filter because of the values that you want to filter on,
specifically where Commission % is greater than zero. You can only
use relational operators with the filter option. Const and Field options
are exact matches only (equal to).
2-26 Navision Attain Objects

8 In the third column, type >0.

9 Click OK to save your table filter.

10 Click OK to save your table relation.

11 With the Properties window open, move your mouse over the Value
field of the TableRelation property. This will display the complete table
relation as text. Make sure that it contains the following (if not redo this
exercise):

Salesperson/Purchaser WHERE (Commission %=FILTER(>0))

12 Close the Properties window and save, compile, and exit the table.

13 Run table 91300 to answer the following questions:

When you use the lookup button on the Salesperson Code field do you
see all the records in the Salesperson/Purchaser table? If not, why not?

Can you enter in the value AH into the Salesperson Code field? If not, why
not?
Basic Tables 2-27

Exercise 2.5.4 Conditional Table Relations

In this exercise, you will add conditions to one of the table relations that you
created in the previous exercises.

You may know that in Navision Attain you can sell several different types of
things, including items, resources, and G/L accounts. In your table, you are
only tracking items. It would be more accurate to have resource numbers
and G/L account numbers as part of your table as well. You could add two
more fields to hold those values but it would be more efficient to use the
one field you already have and let it hold any one of the three types. To
accomplish this, you will need to add a type field to your table so that the
user will know whether the number is an item number, resource number or
G/L account number.

1 Open table 91300 in the Table Designer.

2 Add the following field to the table. Notice that the field number used is
before the Item No. field. This is not critical, but because the Item No.
field will now depend on the Type field, it is normal for the Type field
to be filled in first.

Primary Key Field No. Field Name Data Type

5 Type Option (Account,Item,Resource)

3 To enter the options, open the Properties window and enter the
options in the OptionString field. Enter the properties very carefully.
They must be separated by commas and contain no spaces.

4 Now, change the name of the Item No. field to just No. This will be
more accurate because it may not be an item that was sold.

5 At this point, it will be easier if you save, compile and exit the table.
Whenever you add a new field to an existing table, the table definition
is not updated until you save the table. This step makes the following
steps a bit simpler because the new field will now show up in the list of
fields.

6 Reopen table 91300 in the table Designer and select the No. field.
The table relation for this field needs to be changed. You will give it
the ability to lookup into any of the three tables: G/L Account, Item or
Resource.

7 Open the Properties window for the No. field and click the
TableRelation property.
2-28 Navision Attain Objects

8 Click the assist-edit button to open the Table Relation window.

9 First enter the names of the three tables in the Table column. Put
each table on a new line (you may want to delete the previous line that
was related to the Item table before you begin). However, you cannot
save the TableRelation like this. You still need to set the conditions.
Anytime you have more than one line in the TableRelation dialog you
must have conditions set as well.

10 The conditions are straightforward. If the Type field is Item, the


relationship must be to the Item table and so on. The table relations
will end up with the following values (we will walk through setting the
first condition next):

Condition Table Field Table Filter

Type=CONST(Account) G/L Account

Type=CONST(Item) Item

Type=CONST(Resource) Resource

11 In the Table Relation window, select the first line in the Condition
column.

12 Click the AssistButton k to open the Table Filter window. This is the
same window that we used to set the Table Filters for the table
relation. However, for a condition we are limited to CONST or FILTER
choices (FIELD is not available). See appendix B for more information.

13 In the Field column, select the Type field.

14 In the Type column, select the value CONST (this should already be
the default).
Basic Tables 2-29

15 In the Value column, enter Account. You can also enter the number 0.
and when you press Enter or Tab, the zero will change into the word
Account.

16 Click OK to save the condition.

17 Repeat steps 10-15 for the other two lines in the Table Relation
window.

18 Click OK in the Table Relation window to save your conditional table


relation.

19 Close, save, and compile the table.

Run table 91300 to answer the following questions:

When you use the lookup button on the No. field, what form is displayed?
What if you change the Type field?

Try changing Type to Item and looking up an item number. Now, change
Type to Resource. What happens? Is the value for No. valid?

Now try retyping the value in the No. field after changing the Type as
described in the previous question. What error do you get?
2-30 Navision Attain Objects

2.6 SPECIAL TABLE FIELDS

In addition to the conventional data fields that simply hold values, three
kinds of specialized fields are available for data retrieval:

• SumIndexFields

• FlowFields

• FlowFilter Fields

What Are SumIndexFields?

A SumIndexField is a decimal field that can be attached to a key definition.

This is the fundamental feature of the Navision Attain database that forms
the basis for FlowFields. SumIndexFields permit fast calculation of sums of
numeric columns in tables, even in tables with thousands of records. This
occurs because SumIndexFields are maintained when the database record
is updated.

What Advantages Do SumIndexFields Offer?

They allow fast calculation of sums of columns to be performed and


displayed via FlowFields.

For example, if you want the sum of all the values in the Amount field. In a
conventional database system, the DBMS is forced to access every record
and add each value in the field Amount, a very time-consuming operation
in a database with thousands of records. With Navision Attain, it can be as
little as two accesses (if the best key is used) to sum the Amount for these
records.

This special index structure, a SumIndexField, is associated with a key.


Each key can have at most 20 SumIndexFields. During database design, a
decimal field can be associated with a key as a SumIndexField.

This tells the DBMS to create and maintain a structure that contains the
accumulated sum of values in a column. When a new current key is
selected, any SumIndexFields associated with it becomes accessible.

What Are FlowFields?

FlowFields are a powerful feature of the C/SIDE database system. The


Basic Tables 2-31

FlowField is a fundamental concept that strongly influences the way a


C/SIDE application is designed.

FlowFields and the underlying concept of SumIndexFields have been


designed in order to increase the performance in such activities as
calculating the balance of your customers, which in traditional database
systems involves a series of accesses and calculations before a result is
available. Why such a result will be immediately available when you use
FlowFields will be clear as you read through the rest of this chapter.

FlowFields are not a permanent part of the table data. A FlowField can be
thought of as a virtual field, which is an extension to the table data.
Actually, the information in the FlowFields exists only at run time. The
values in FlowFields are automatically initialized to 0 (zero). To update a
FlowField, you must use the C/AL function <Record>.CALCFIELDS. Notice
that when a FlowField is the direct source expression of a control on a form
the FlowField is automatically calculated when the form is displayed.

There are seven types of FlowFields:

FlowField Type Field Type Description

Sum decimal The sum of a specified set within a column


in a table

Average decimal The average value of a specified set within


a column in a table

Exist Boolean Indicates whether any records exist within a


specified set in a table

Count integer The number of records within a specified


set in a table

Min any The minimum value in a column within a


specified set in a table

Max any The maximum value in a column within a


specified set in a table

Lookup any Looks up a value in a column in another


table

Calculation Formulas and the CalcFormula Property

A FlowField is always associated with a calculation formula that determines


2-32 Navision Attain Objects

how the value in the FlowField is calculated. Below is an example of a valid


value for the CalcFormula property:

Sum("Cust. Ledger Entry".Amount


WHERE (Customer No.=FIELD(No.),
Initial Entry Global Dim. 1 Code=FIELD(Global
Dimension 1 Filter),
Initial Entry Global Dim. 2=FIELD(Global
Dimension 2 Filter),
Posting Date=FIELD(Date Filter),
Currency Code=FIELD(Currency Filter)))

Using FlowFilter Fields in the Calculation Formula

End-users may want to limit calculations so that they include only those
values in a column that have some specific properties. For example the
user may want to sum up only the amounts of customer entries that are
entered in April. This is possible if the application has been designed using
FlowFilter fields in connection with the FlowFields.

Exercises in Implementing SIFT

In this subsection, you will add a calculated field to the


Salesperson/Purchaser table to display the sum of related records in the
table you created in section 2.5. To complete these exercises, you must
first complete the exercises in section 2.5.

Exercise 2.6.1 Calculating the Sums Manually

In this exercise, you will calculate sums for the data you enter. This
information will help us confirm the sums that get calculated automatically.

1 Open the Object Designer and run table 91300.

2 Delete all of the current records in the table. This will ensure that the
totals you get are the same as the ones in the answer guide. The
easiest way to delete all the records is to click in the upper left gray
box of the form (this should select all the records) and then press F4
(this should prompt you for confirmation and then delete the records).

3 Now that the table is empty, enter the following records into the table.
Make sure you use the values given.

Line Salesperson Type Item No. Amount


No. Code

10000 JR Item 70000 300.00


Basic Tables 2-33

20000 MF Account 2910 150.00

30000 JR Account 2920 200.00

40000 MF Item 70000 100.00

50000 PS Item 70000 110.00

60000 JR Item 70010 50.00

70000 JR Resource LIFT 500.00

80000 MF Resource LIFT 550.00

90000 PS Item 70010 75.00

4 Calculate the sum for the entire table and for every unique
Salesperson Code. Write down the sums in the following table:

Which Total Total Amount

For JR

For MF

For PS

For ALL

Note that this would be much easier if you could sort the records by
Salesperson Code first. Of course, the only way to do this is to add a key.
So, DO NOT do this yet.

Close the table.

Exercise 2.6.2 Creating a FlowField

In this exercise, you will create a FlowField that displays the sum of records
in the Sales Transaction table (91300).

1 Open table 13 (Salesperson/Purchaser) in the Object Designer.

2 Add a new field to the table with following properties

Primary Key Field No. Field Name Data Type

91400 Sales Decimal


2-34 Navision Attain Objects

The field number must be between 50,000 and 99,999 because


table 13 is a base application table (its number is less than
50,000).

The data type must be decimal because you want to display a sum
(averages require a decimal as well). A sum FlowField calculates a
decimal value.

3 Open the Properties window for the new field.

4 Go to the Field Class property and change it to FlowField (FlowFields


are used to calculate values from another table).

5 A new property called CalcFormula is now available. Go to this new


property.

6 Click the assist-edit button to open the Calculation Formula window.


This is where you tell the FlowField how to calculate its value.

7 Enter the following values into the Calculation Formula window:

Property Name Value

Method Sum

Table 91300

Field Amount

8 Click OK to save the calculation formula (clicking the x on the dialog


will not save your changes).

9 Close, save and compile the table. If you receive a permissions error,
the ID that you gave the field is incorrect (see step 2).

You have now successfully created a FlowField. The next step is to test it.
Basic Tables 2-35

Exercise 2.6.3 Testing your FlowField

In this exercise you will test your new FlowField.

1 Run table 13 (Salesperson/Purchaser).

What happened when you tried to run the table?

What caused the error message?

What do we need to change to correct the problem (hint: read the error
message very carefully)?

Exercise 2.6.4 Creating a SumIndexField

For a sum to be calculating automatically, you must create a


SumIndexField. This is a field tied to a key (index) that sums records sorted
by that key (index). For your FlowField to calculate, you must create a
SumIndexField for it.

You can simply let the error message tell you what to do. In a moment, you
will learn the correct procedure.

1 Open the Sales Transaction table that the error message mentions in
the Table Designer.

2 Click View, Keys to open the Keys Designer. This is where you will
create your key and your SumIndexField.

3 Add the following SumIndexField to the primary key:

Enabled Key SumIndexFields

x Line No. Amount


2-36 Navision Attain Objects

4 Close, save and compile the table.

To test your SumIndexField, you need to view your FlowField. Run table 13
(Salesperson/Purchaser).

Were there any errors this time? Why or Why not?

Fill in the following table with the values displayed the new FlowField,
Sales.

Which Total Sales

For JR

For MF

For PS

Do the totals seem correct? What is suspected about them?

Do they match any of the values from exercise 5.4.1 (your manual sums)?
Which ones do they match?

What seems to be wrong with your FlowField?


Basic Tables 2-37

Exercise 2.6.5 Filtering the FlowField

In this exercise, you will correct the FlowField that you started above. The
problem with the FlowField was that you left out a part of the CalcFormula.
For most FlowFields, you must use a Table Filter. Table filters allow the
user to Sum some of the records in the table instead of all the records.

In the FlowField that you created above, you only want to sum records in
the Sales Transaction table that have a particular Salesperson Code. For
example, if the Code field in the Salesperson/Purchaser table is ‘PS’, then
we only want to sum records in the Sales Transaction table that have a
Salesperson Code of ‘PS’.

Now, add this logic to your FlowField CalcFormula.

1 Open table 13 (Salesperson/Purchaser) in the Table Designer.

2 Select the Sales field.

3 Open the Properties window and select the CalcFormula property.

4 Click the assist-edit button to open the Calculation Formula window.

5 Notice that you left the Table Filter field blank in the previous
exercise. This is the part of the CalcFormula that you need to
complete. When you leave this empty, the calculation in your
FlowField is based on all the records in the table.

6 Click the assist-edit button to open the Table Filter window. Set a
filter like the following:

Field Type Value OnlyMax Limit ValueIs


Filter

Salesperson Field Code


Code

The Field column corresponds to fields in the Sales Transaction table (the
table you are summing). Because you have the Type column set to Field,
the Value column represents fields in the table you are currently designing
(Salesperson/Purchaser).
2-38 Navision Attain Objects

7 Click OK to save your filter.

8 Click OK to save your CalcFormula.

9 Close, save, and compile the table.

10 Run the table to see if your changes worked.

What happened when you tried to run the table?

What caused the error message?

What do we need to change to correct the problem (hint: read the error
message very carefully)?

Exercise 2.6.6 A Process for Creating a SumIndexField

In this exercise, you will learn the proper procedure for deciding how to
create your SumIndexFields.

The first thing to do is to look at the CalcFormula property of the FlowField.


This will tell you how to create your SumIndexField.
Basic Tables 2-39

1 Open table 13 (Salesperson/Purchaser) in the Table Designer.

2 Select the Sales field.

3 Open the Properties window and select the CalcFormula property.

4 Click the assist-edit button to open the Calculation Formula window.

5 Write the name of the table that is named in the window in the
following space.

Table Name: _____________________________

This is the table that the SumIndexField must be created in.

6 Write the name of the field that is named in the window in the following
space.

Field Name: _____________________________

This is the field that must be attached to a key, to create the


SumIndexField you need. This field must be a decimal field and must
exist in the table you wrote down in step 5.

7 Click the assist-edit button in the Table Filter field to open the Table
Filter dialog. Write down all of the fields that are mentioned in the Field
column (the first column). (You may not use all of these spaces.)

Field Name 1: _____________________________

Field Name 2: _____________________________

Field Name 3: _____________________________

These fields are the fields in the table you are summing that you need
to sort by. You need a key with all of these fields in it. The order of the
fields in the key is not important for this FlowField, although, you may
want to use this key for other things as well.

8 Now, you know the table, the field and the key. Close this table and
design the table you identified in step 5.

9 Click View, Keys to open the Keys Designer. This is where you will
create your key and your SumIndexField.

10 Create a new secondary key that has the following properties:


2-40 Navision Attain Objects

Enabled Key SumIndexFields

x Salesperson Amount
Code

If this does match what you wrote down in steps 5-7, start over with
step 1.

11 Close, save and compile the table.

To test your SumIndexField, you need to view your FlowField. Run table 13
(Salesperson/Purchaser).

Were there any errors this time? Why or Why not?

Exercise 2.6.7 Creating a FlowFilter

In this exercise, you will extend the functionality of your FlowField to


include a FlowFilter. A FlowFilter allows the user to dynamically change the
Table Filter part of the FlowField.

You will create a FlowFilter that allows the user, you, to change the sum
based on the Type field in the Sales Transaction table. This will allow the
user to use your FlowField for four different sums – total for accounts sold,
total for items sold, total for resources sold, or the total of all sales.

You begin by modifying the master table (table 13,


Salesperson/Purchaser).

1 Open the Salesperson/Purchaser table in the Table Designer.

2 Add a new field that has the following properties:


Basic Tables 2-41

Primary Key Field No. Field Name Data Type

91401 Type Filter Option


(Account,Item,Resource)

Remember that the options must be entered exactly as they appear in


this table.

3 Select the new field and open the Properties window.

4 Change the Field Class property to FlowFilter. Now this field is a


FlowFilter field, but you aren’t done yet. If you were to run the table
now, you could change the Type Filter field, but nothing would
happen. You need to make your FlowField use the new FlowFilter.

5 Close, save, and compile the table. This step makes the next few
steps easier.

6 Open table 13 in the table Designer again.

7 Select the Sales field.

8 Open the Properties window and select the CalcFormula property.

9 Click the assist-edit button to open the Calculation Formula window.

10 In the Table Filter field, click the assist-edit button to open the Table
Filter window. This is where you need to change the FlowField so that
it will use the FlowFilter.

11 Click on an empty line (this should be the second line in the dialog).
Enter the following in the empty line:

Field Type Value OnlyMax Limit Values


Filter

Type Field Type Filter

Remember that the Field column corresponds to fields in the Sales


Transaction table. Because you have the Type column set to Field, the
Value column represents fields in the table you are currently designing
(Salesperson/Purchaser).
2-42 Navision Attain Objects

12 Click OK to save your filter.

13 Click OK to save your Calculation Formula.

14 Close, save and compile the table.

15 Run the table to see if your changes worked.

You may not notice any difference, but that is good. It means that nothing
broke. In the next exercise, you will test the FlowFilter itself.

Exercise 2.6.8 Using a FlowFilter

In this exercise, you will learn how to use the FlowFilter as the user would.
You will also learn that changes you make to a FlowField can have
unexpected results.

1 Run table 13 (Salesperson/Purchaser).

2 Look at the Sales column and double check the values.

3 You may notice that the Type Filter field does not appear on our form.
This is because FlowFilters have a special form. Click the FlowFilter
button on the toolbar or click View, FlowFilter to display this special
form. This is the FlowFilter window. This is where you can change the
value of a FlowFilter.

Remember that changing the value of the FlowFilter should change


the value of your FlowField.
Basic Tables 2-43

4 In the Filter column for the Type Filter field, select the type Item.
Nothing has happened yet. You still need to click OK or Apply.

5 Click OK.

What happened?

Why did you only get the message after you set the FlowFilter?

What is the error message that you received?

Have you seen an error message like this before?

What is the next step that you should take to correct the problem?

Exercise 2.6.9 Correcting the Problem.

1 Open the Sales Transaction table in the Table Designer.

2 Click View, Keys.

3 Add the Type field to the secondary key that you created earlier so
that the key looks as follows:

Enabled Key SumIndexFields

x Salesperson Amount
Code,Type
2-44 Navision Attain Objects

You could create a whole new key, but that is not necessary. This one key
will work for the FlowField whether you are using the FlowFilter or not.

To test your fix, repeat steps 3-5 from the previous exercise.

Did everything work correctly that time?


Basic Tables 2-45

2.7 MODIFYING SOME PROPERTIES

In this section, you will investigate some very useful properties and why
you would use them.

Exercise 2.7.1 The NotBlank Property

In this exercise, you will discover the need for the NotBlank property. You
will begin by simply entering some records.

1 Run table 91100 (Vehicle).

2 Press F3 to insert a new record.

3 Without entering a value in the Model or Serial No. fields, click the
Description field.

4 Enter New Vehicle as the description.

5 Click on another record in the table (it does not matter which one).
Notice that your ‘New Vehicle’ record is inserted into the table.

What is the “name” of the record (remember that the name is the value
of the primary key fields)?

What happens if you repeat steps 2-5 above?

How could we eliminate blank records being put into the table by
accident?

6 Open table 91100 (Vehicle) in the Table Designer.

7 Open the Properties window for the Model field.

8 Change the value of the NotBlank property to Yes.

9 Close, save, and compile the table.

10 Run the table.


2-46 Navision Attain Objects

11 Repeat steps 2-5.

What happens this time?

What must you do to insert a new record now?

Note

If you try to use the NotBlank property on fields that are not in the Primary
key, it will not behave the same way. Repeat the process above for the
Description field and see if NotBlank works the same way on it.

Exercise 2.7.2 The Editable Property

In this exercise, you will discover the need for the Editable property. You
will begin by modifying some records.

1 Run table 13 (Salesperson/Purchaser).

2 Click on the Sales column. Notice that this field is editable (can be
changed). Remember that this is the FlowField that you created.
FlowFields are calculated values.

3 Click on the Sales field for salesperson PS.

4 Enter 500 for the new Sales value.

What happened?

Did the change last (if you close the table and run it again, is the value still
500 for PS)?

Run table 91300 (Sales Transaction) and manually calculate the sum of
the values for PS (you may want to change the sort first).

What is the new sum? What was the old sum (section 2.7.1)? What is the
difference?
Basic Tables 2-47

Can you identify the line that may have changed the sum?

Did you enter this line? How did it get entered?

This is not a good situation. Users looking at this FlowField must not be
allowed to accidentally change the sum. In fact, for other types of
FlowFields, (average, exist and so on) the user would receive an
immediate error, if they tried to change them. So, it is a good practice to
make most FlowFields non-editable.

To make a field (FlowField or any other type) non-editable:

1 Open table 13 in the Table Designer.

2 Click on the field that you want to change (the Sales field).

3 Open the Properties window.

4 Click on the Editable property (NOT the Enabled property).

5 Change the value to No.

6 Close, save, and compile the table.

7 Test your change by running the table and trying to edit the field.

Note

In some situations, the behavior that you observed is exactly what you want
to happen. This functionality is used in the G/L Budgets, for example, to
make it easier for the user to enter budget information. You may want to
look at the budgets to see how this is done.

Exercise 2.7.3 The DecimalPlaces Property

In this exercise, you will change the DecimalPlaces property of a field to


allow for more precision.

1 Run table 91300 (Sales Transaction).


2-48 Navision Attain Objects

2 Enter a new record with the following values (notice that the amount
has three decimal places).

Line Salesperson Type Item No. Amount


No. Code

130000 JR Item 70000 301.155

Were you able to enter the amount correctly?

What error did you get?

By default the DecimalPlaces property is set to 2:2. The number before the
colon is the minimum number of decimals that will be displayed to the user.
The number after the colon is the maximum number of decimals that the
user can enter.

In your case, you cannot enter three decimal places because there is a two
after the colon. To change this, follow these steps:

1 Open table 91300 (Sales Transaction) in the Table Designer.

2 Open the Properties window for the Amount field.

3 Click on the DecimalPlaces property.

4 Enter the value 2:3.

5 Close, save, and compile the table.

6 Run the table.

7 Finish entering the Amount now and press Enter.

What happened?

What is displayed in the field if you enter the Amount 234.1 and press
Enter?
Basic Tables 2-49

What is displayed in the field if you enter the Amount 234 and press Enter?

What is displayed in the field if you enter the Amount 234.110 and press
Enter?

Exercise 2.7.4 The CaptionML and OptionCaptionML Property

All objects and fields have a CaptionML property. This property allows the
user to switch languages and have the captions shown in the language
they select. Additional languages can be added and for each language the
CaptionML property value is set to the language’s correct term. The English
(United States) (ENU) language is mandatory. When creating a new table,
go the Table properties to populate the CaptionML for the table name. See
the example for the Name field CaptionML below:

For Option Data Types the OptionCaptionML property must be filled out as
well.
2-50 Navision Attain Objects

The following picture shows the Properties window for the Document
Type field:
Basic Tables 2-51

2.8 TYPES OF TABLES AND THEIR CHARACTERISTICS

There are numerous standard types of tables in Navision Attain. The


following table lists the most common types of tables and some examples
of each. A more detailed description of each type appears in the following
subsections.

Understanding the standard types of tables in Navision Attain will help you
to quickly understand how different areas of the application are designed.

Type Brief Description Examples

Master contains information about the Customer, Vendor,


primary focus subject of its Item
functional area.

Supplemental stores information about a Language,


supplemental subject used in one Currency
or more functional areas.

Setup stores one record that holds G/L Setup, Sales


general information about its &Receivables Setup
functional area.

Register a "table of contents" for its G/L Register, Item


corresponding Ledger table or Register
tables.

Subsidiary contains information which is Item Vendor, FA


subsidiary to either a Master table Depreciation Book
or a Supplemental table or both.

Ledger contains the transactional Cust. Ledger Entry,


information that is the primary Item Ledger Entry
focus of its functional area.

Journal the primary transaction entry Purchase Journal,


table for a functional area. Item Journal

Document secondary transactional tables Sales Header / Sales


that allow entries in a functional Line, Finance
area or into multiple functional Charge Memo
areas at once. This is actually Header / Finance
implemented as a pair table. Charge Memo Line,
Reminder Header /
Reminder Line
2-52 Navision Attain Objects

Type Brief Description Examples

Document Contains the transaction history Sales Invoice


History for documents that have been Header / Sales
posted. Invoice Line, Issued
Fin. Charge Memo
Header / Issued Fin.
Charge Memo Line,
Issued Reminder
Header / Issued
Reminder Line

Master Table Characteristics

A Master table contains information about the primary focus subject of its
functional area. For example, the Customer table, which is the primary
focus of the Sales & Receivables functional area, is a Master table.

Generally, many other tables are related to a Master table and the Master
table itself is related to many other (usually Supplemental) tables.

There is usually a Ledger table that is related to a Master table. Master


tables also contain many FlowFilters and FlowFields, most of which relate
to its corresponding Ledger table.

Most functional areas have only one Master table, though occasionally,
there will be two Master tables for a functional area.

Naming Master Tables

The name of this table is the name of one of the records in the table.

For example, the Customer table is so named because each record within
it contains information about one customer.

Primary Key and Other Standard Fields

The Primary Key of a Master table is a Code field of length 20, named
"No." or occasionally "Code".

The description field of this table is a Text field of length 30, named "Name"
or "Description".

These two fields are included in the DataCaptionFields property of the table
so that these will display in the title bar of this table's forms.
Basic Tables 2-53

Associated Forms

There are three or more forms that are used with a Master table.

• Card Form

• List Form

• Statistics Form

The Associated Card Form

First is a Card Form that is used to edit the records in the Master table.

The name of this form will be the name of the table followed by the word
"Card". Thus the Card form for the Customer table will be named
Customer Card.

It will have at least one additional menu button (besides the usual OK,
Cancel and Help) and this has the same name as the table. The menu
button will provide links to other forms giving related or subsidiary
information. One of these choices will be a link to the List form that can be
triggered by pressing F5 on the keyboard. Another of these choices will be
a link to the form showing the related Ledger table that can be triggered by
pressing Ctrl+F5 on the keyboard. Another of these choices will be a link to
the related Statistics form that can be triggered by pressing F9 on the
keyboard.

The Associated List Form

The second form used with a Master table is a List Form, which is used to
view the records in the master table. Unlike the card form, this form cannot
be used to edit the master table.

The name of this form will be the name of the table followed by the word
"List". Thus the List form for the Customer table will be named Customer
List.

It will have at least one additional menu button (besides the usual OK,
Cancel and Help) with the same name as the table. It will provide links to
other forms giving related or subsidiary information. One of these choices
will be a link to the Card form that can be triggered by pressing Shift+F5 on
the keyboard. Another of these choices will be a link to the form showing
the related Ledger table that can be triggered by pressing Ctrl+F5 on the
keyboard. Another of these choices will be a link to the related Statistics
2-54 Navision Attain Objects

form that can be triggered by pressing F9 on the keyboard.

This form is set as the LookupFormID property and the DrillDownFormID


property of the table, since it is used not only for viewing but also for
Lookups and Drill downs into this table.

The Associated Statistics Form

The third form used with a Master table is a Statistics Form, which is used
to view calculated information about the record in the Master table. This
information is put on a separate form from the Card form for performance
reasons since this information is calculated.

The name of this form will be the name of the table followed by the word
"Statistics". Thus the Statistics form for the Customer table will be named
Customer Statistics.

Supplemental Table Characteristics

A Supplemental Table is a table in which information is stored about a


supplemental subject used in one or more functional areas.

An example of this would be the Currency table, which contains information


about different currencies. This is not the primary focus of any functional
area but it is important to practically all of them. Generally, Supplemental
tables are not related to other tables although many other tables of all types
are related to Supplemental tables.

Naming Supplemental Tables

The name of this table is the name of one of the records within the table.
For example, the Currency table is named "Currency" because each record
within it contains information about one currency.

Primary Key and Other Standard Fields

The Primary Key of a Supplemental table is a Code field of length 10,


named "Code".

The description field of this table is a Text field of length 30 or 50, named
"Description". Some Supplemental tables do not contain a description field
and some contain a description field whose name is "Name".
Basic Tables 2-55

Associated Forms

The form used for a Supplemental table is a Tabular Form as described


before. The name of this form is the plural of the name of the Supplemental
table. Thus, the form that is used to edit the Currency table is named
"Currencies".

This form generally has no buttons except for the standard OK, Cancel and
Help. This form is set as the LookupFormID property of the table since it is
used not only for edit but also for Lookups into this table.

Subsidiary Table Characteristics

A Subsidiary Table contains information which is subsidiary to either a


Master table or a Supplemental table or both.

For example, the Item Vendor table is a table that contains subsidiary
information (vendor numbers) for the Item table in the Inventory functional
area.

Primary Key and Other Standard Fields

The Primary Key for the Subsidiary table will contain a field for each table
to which it is subsidiary, each of which is related to that table.

For example, the Primary Key fields for the Item Vendor table include an
Item No. field (related to the Master table Item) and a Vendor No. field
(related to the Master table Vendor).

The Primary Key can also contain an Integer as the last field (named Line
No.) to differentiate multiple records with the exact same subsidiary
relationship. For example, the Employee Qualification table has an
Integer field in the Primary Key to differentiate two records for the same
Employee.

Subsidiary tables are generally not related to other tables except for the
Primary Key fields mentioned before. Other tables are generally not related
to a Subsidiary table due to the fact that each Subsidiary table has multiple
fields in the Primary Key.

Subsidiary tables usually do not contain description fields.

Naming Subsidiary Tables

The name of this table is generally made up of the names of the table or
2-56 Navision Attain Objects

tables to which it is subsidiary or something close to that.

For example, the table that is subsidiary to both the Vendor table and the
Item table is named Item Vendor. Whatever it is, it is a singular name that
describes one record contained within the table.

Associated Forms

A Subsidiary table uses one form for editing and viewing purposes and this
form is usually called from a button on the Master or Supplemental form to
which it is subsidiary.

The name of this form is usually the plural of the name of the table.

If the Primary Key for the Subsidiary table contains an Integer, the form will
be a Worksheet form and it will not contain any of the Primary Key fields.
Instead, the Primary Key fields other than the Integer will be filtered so that
they are viewed and set automatically.

If the Primary Key for the Subsidiary table does not contain an Integer, the
form will be a Tabular form and it will not contain the Primary Key field of
the master table. Instead, this field will be filtered so that it is viewed and
set automatically.

In both cases, the form is linked back to the form that called it up so that if
the record there is changed, the filters on this form are also changed. This
ensures that the correct related records are always in view.

Ledger Table Characteristics

A Ledger Table contains the transactional information that is the primary


focus of its functional area. For example, the Customer Ledger Entry
table which contains all Sales and Receivables transaction information and
which is the primary focus of the Sales and Receivables functional area, is
a Ledger table.

This table is very much like a Subsidiary table, in that, it is related to the
corresponding Master table, but it has different characteristics, as we will
see. It is also related to many other tables, mostly Supplemental tables.
Register tables are related to Ledger tables but rarely will another table be
related to a Ledger table.

There is normally one Ledger table per functional area, although


occasionally there are two.
Basic Tables 2-57

Naming Ledger Tables

The name of the Ledger Table is usually the name of the Master table to
which it is related, plus the words "Ledger Entry" describing one of the
records in it (an entry). Since this is sometimes lengthy, the name is
sometimes abbreviated.

For example, the Customer Ledger Entry table is actually named Cust.
Ledger Entry.

Sometimes, when there is more than one Master table, the name is the
functional area followed by the words "Ledger Entry". Thus, the Ledger
table for the Payroll functional area is named Payroll Ledger Entry.

Ledger tables cannot be modified by users except for some highly


controlled exceptions.

These exceptions never include the ability to add or delete a record.

Primary Key and Other Standard Fields

The Primary Key of a Ledger table is an Integer named "Entry No.". This
Primary Key is always generated automatically by the posting routine that
controls this Ledger table.

There is always a field in the Ledger table that has a table relation to the
Master table associated with this ledger table.

The description field of this table is a Text field of length 50 named


Description.

In addition to the Primary Key, Ledger tables generally have numerous


Secondary Keys, many of which have SumIndex fields attached to them.
These are used in conjunction with the FlowFields on the Master table to
calculate information for the user. Because of this, at least one, and usually
more than one of the Secondary Keys have the field that is related to the
Master table as the first field in the key.

Associated Forms

A Ledger table uses a List Form to display information to the user. This
form is named with the plural of the Ledger table. For example, the name of
the form that displays records from the Customer Ledger Entry table is
Customer Ledger Entries.
2-58 Navision Attain Objects

This form is set as the LookupFormID property and the DrillDownFormID


property of the table since it is used not only for viewing but also for
Lookups and Drill downs into this table.

This form can be displayed from the Master table forms by pressing the
Ctrl+F5 keys on the keyboard.

Register Table Characteristics

A Register Table is a "table of contents" for its corresponding Ledger table


or tables.

There is one record per posting process and the Register table
corresponds more closely to the posting routine rather than the functional
area.

For example, the table that contains the list of entries made to the
Customer Ledger Entry table is the G/L Register table. This is because
the Customer Ledger Entries are posted from the General Journal table
using the General Journal posting procedures. The Register Table is
related to its corresponding Ledger table or Tables.

Naming Register Tables

Register Tables are named according to the posting function followed by


the word "Register". Thus the Register updated by the General Ledger
posting function is named G/L Register.

The user can never modify the Register table.

Primary Key and Other Standard Fields

The Primary Key of a Register table is an Integer field named "No.". The
Primary Key is always generated automatically by the posting routine that
controls this Register.

Other standard fields for the Register table include two fields, both Integer
fields related to the corresponding Ledger table, called "From Entry No."
and "To Entry No."

Register tables usually do not contain description fields.

Associated Forms

A Register table uses a List form to display its information to the user.
Basic Tables 2-59

This form generally has the same name as the Register table.

It contains a menu button named "Register" which contains links to other


List forms displaying the corresponding Ledger table or tables.

Journal Table Characteristics

A Journal Table is the primary transaction entry table for a functional area.

All transactions, whether entered by the user directly or generated from


another posting routine, pass through this table to eventually be posted to a
Ledger table.

Journal tables are related to many other tables including the Master table,
Supplemental tables, Subsidiary tables and even the corresponding Ledger
table (for application purposes). Other tables are not related to the Journal
table.

Because of their use for transaction entries, Journal tables have more
trigger code than most other table types.

Naming Journal Tables

The name of this table is the name of the type of transaction being posted,
followed by the words "Journal Line".

For example, the name of the table in which the user enters transactions to
the Resource functional area is Resource Journal Line. Each record in
the journal table contains one line from the journal.

The Journal table is usually related to two corresponding Supplemental


tables, the Journal Template table and the Journal Batch table. These
tables let users split up data entry in various ways and let them set optional
information that applies to the entire Journal.

The names of these two tables are the same as the name of the Journal
table, except followed by Journal Batch or Journal Template rather than
Journal Line. Thus, the two corresponding tables for the Resource Journal
Line are named Resource Journal Template and Resource Journal
Batch.

Primary Key and Other Standard Fields

The Primary Key for the Journal table is made up of three fields, the field
that is related to the Journal Template table, the field that is related to the
2-60 Navision Attain Objects

Journal Batch table and an Integer field named Line No..

The description field of this table is a Text field of length 50 named


Description.

Associated Forms

The form that is used for a Journal table is a Worksheet Form, which is
used to make entries to this table.

This form is named the same as the table, except without the "Line". Thus
the Worksheet form for the Resource Journal Line table is named
Resource Journal. Sometimes, the form is named for the type of data
being input. For example, one of the (many) Worksheet forms used with the
Gen. Journal Line table is called Sales Journal.

None of the Primary Key fields are included on this form.

When it is called, it is filtered by the Template and Batch fields, and the
AutoSplitKey property of the Worksheet automatically sets the Line No.
field.

The Worksheet form always includes a menu button that has the same
name as the related Master table. It includes a way to call up the Card form
for the Master table that can be triggered by pressing Shift+F5 on the
keyboard. It also has a way to call up the Ledger for that current Master
record, which can be triggered by pressing Ctrl+F5 on the Keyboard.

The Worksheet form also always includes a menu button that is named
"Posting", which lets the user print the test report, post, or post and print a
register and sometimes includes a choice to reconcile. The Worksheet form
also usually includes other buttons that lets the user perform various
processing functions.

Document Table Characteristics

Document Tables are secondary transactional tables that allow entries in a


functional area, or into multiple functional areas at once. They are
secondary only in that its information is posted to ledgers through journal
tables, and not directly.

For most users, it is the primary means of entering data as it is the one
most often used. Because they are used for transaction entries, Document
tables have more trigger code than most other table types.
Basic Tables 2-61

There are actually two types of Document Tables:

• Document Header table

• Document Line table

Document Header Table

The Document Header table holds the main transaction information. For
example, in the case of a sales transaction, the Sales Header table
contains information pertaining to the order or invoice as a whole.

Document Line Table

The Document Line table holds the detailed information for the transaction.
For example, in the case of a sales transaction, the Sales Line table
contains information about each individual line of the order or invoice. The
Document Line table is a Subsidiary table to the Document Header table.

Like Journal tables, Document tables are related to numerous other tables,
including Master, Supplemental, and Subsidiary tables, but rarely is
another table related to a Document table.

Naming Document Tables

The name of the Document Header table is the name of the transaction or
document, plus the word "Header". For example, the Document Header
table that contains Sales transactions is named Sales Header. Each record
contains one sale (order or invoice).

Another example, the Document Header table that contains Finance


Charge Memo transactions is named Finance Charge Memo Header.
Each record contains one Finance Charge Memo.

The name of the Document Line table is the name of the transaction or
document, plus the word "Line". For example, the Document Line table that
contains Sales transactions is named Sales Line. Each record contains
one line from a sale (order or invoice).

Another example, the Document Line table that contains Finance Charge
Memo transactions is named Finance Charge Memo Line. Each record
contains one line from a Finance Charge Memo.
2-62 Navision Attain Objects

Primary Key and Other Standard Fields

For most Document Header tables, the Primary Key is a Code field of
length 20 containing the document number and named No..

Some Document Header tables contain multiple types of documents each


referring to the same transaction. For example, the Sales Header table
contains Invoice documents, Credit Memo documents, Sales Order
documents and so on. In these cases, the Primary Key has two fields – an
Option field named Document Type and a Code field of length 20 named
No..

For most Document Line tables, the Primary Key has two fields – a Code
field of length 20 containing the document number and an Integer field
named Line No.. The Code field is table related to the Document Header
table, and so is named according to that table's name (without "Header")
followed by that table's Primary Key field. For example, the Code field in
the Primary Key of the Finance Charge Memo Line table is named Finance
Charge Memo No..

In the case where the Document Header has a document type, the Primary
Key of the Document Line table has 3 fields – an Option field named
Document Type, a Code field of length 20 named Document No., and an
Integer field named Line No.. Again, the Code field is table related to the
Document Header table.

Associated Forms

A Document Header table uses a special kind of Card form to display one
header record at a time for the user to view and edit information.

The name of this form is the name of the document that it displays. This is
true even if the table can contain multiple types of documents since, in this
case, the form is set up to only view information from one type. It contains
tabs to split the fields into logical groups to make it easier for the user to
edit the information.

The Document Header form always includes a menu button which is


named "Posting", which lets the user print the test reports, post, post and
print the Document, or post a batch of these documents.

The form also includes other buttons that let the user perform various
processing functions.

The thing that makes a Document Header form different from a Card form
Basic Tables 2-63

is that it contains a sub-form control, which in turn contains a Document


Lines form.

A Document Line table uses a special kind of Worksheet form to display


multiple line records at a time for the user to view, and letting the user edit
one at a time.

The name of the form is the name of the document followed by either
"Lines" or "Sub-Form". Since this name never shows, it is not that critical.

What is critical is that the size of this form is exactly the same as the size of
the sub-form control in which it is displayed.

None of the Primary Key fields should be included on this form as the form
is filtered (using a link) for all of the Primary Key fields except the Integer
field, which is handled automatically by the AutoSplitKey property of the
Worksheet.

The Document Header table also uses a List form to let the user view
multiple documents at the same time.

The name of this form is, like most List forms, the name of the table
(without the word "Header") followed by the word "List". This List form can
be invoked from the Header form by pressing the F5 key on the keyboard.

Document History Table Characteristics

Document History tables are to Document tables what Ledger tables are to
Journal tables.

When a Document is posted, part of that posting process is copying the


Document Tables to their corresponding Document History tables.

To aid with that copying process, the Document History table generally has
the same fields with the same field numbers, names and properties as the
original Document tables.

Since the Document History tables record posted transactions, they are
generally not editable by the user, although they can be deleted if the user
has that permission.

Other than the above, the Document History tables and forms are the same
as the corresponding Document tables.

Naturally, the sub-form is a List form rather than a Worksheet form since
2-64 Navision Attain Objects

modifications are not allowed.

And the names include either the word "Posted" or "Issued" to indicate that
it is a history table rather than a transaction entry table.

Setup Table Characteristics

A Setup Table is a table that is designed to hold only one record. This
record contains various fields that are used to select options for Navision
Attain or to hold data that is applicable to the company as a whole.

Generally, no tables are related to a Setup Table, although Setup Tables


can be related to other tables, usually Supplemental Tables.

Naming Setup Tables

The name of this table is usually the name of the functional area it is meant
to set up, followed by the word, "Setup". For example, the table that
contains the setup information for the General Ledger functional area is
named General Ledger Setup. One exception to this rule is the Company
Information table.

Primary Key and Other Standard Fields

The Primary Key for this table is a Code field of length 10, named Primary
Key. It is always left blank as only one record per table is allowed. There is
no description field for this table type.

Associated Setup Form

There is only one form set up for this table, and it is a Setup Form as
described in the next section. The form has the same name as the table.
The primary key field is not included on this form.

Note

There are some tables containing the word "Setup" in their name, which
have more than one record. These tables generally follow the rules of the
Subsidiary Tables described previously, not the rules outlined here.
Basic Tables 2-65

2.9 ANSWERS TO THE QUESTIONS

This concludes the table exercise section. If you did not understand what
you did in this chapter, be sure to reread the sections about tables and then
redo these exercises.

It is critical that you grasp the concepts you learned in this chapter. Tables
are the foundation on which everything else is built in Navision Attain.

Here are the answers to all the questions in the previous sections:

Exercise 2.2.1 Investigating existing tables

What is the option string for the Reserve field in the Customer table?

Never,Optional,Always

What is the difference between the calculation formulas of the Balance


field and the Balance At Date field in the G/L Account table?

The Balance At Date field has one more filter line in the Table Filter that
includes the Date Filter.

What type of field is the Date Filter field in the G/L Account table?

Date, FlowFilter

What is the value of the TableRelation property of the Currency Code field
in the Customer table?

Currency

Exercise 2.3.1 Creating a Simple Table

No questions here

Exercise 2.3.2 Adding Data

What problem did you encounter?

You cannot enter the second record. You get the error: The record already
exists.
2-66 Navision Attain Objects

Why can’t you enter the second record above?

The Primary key is only the Model field. It is the first field in the table and
that means that the Model field must be unique for every record.

Exercise 2.4.1 Setting the Primary Key

No questions here

Exercise 2.4.2 Creating Secondary Keys

No questions here

Exercise 2.4.3 Using Secondary Keys

Look at the records that have a Date of Mfg. of 01/15/00. What order are
these records in since they have the same date?

They are in order by Transmission, the second field in the secondary key.

Look at the records that have the same Date of Mfg. and the same
Transmission. What order are these records in?

They are in Primary Key order.

What does this tell you about secondary keys?

If any Primary Key field is not used in the secondary key, it is added to the
end of the secondary key.

Exercise 2.5.1 Simple Table with Table Relations

Enter ‘a’ in the Salesperson Code field. What happens when press Enter?

The client finds the first value in the table that has an A as the first letter
and chooses that record for you.

Type ‘XY’ into the Salesperson Code field. What happens when press
Enter?

You receive an error because XY does not exist in the


Salesperson/Purchaser table.
Basic Tables 2-67

Exercise 2.5.2 Renaming Records

How long did it take to change that value? Was it longer than you
expected?

It took several seconds

Yes.

Check the data in table 91300 (Sales Transaction) by running it. Did any
of the records here change? Why?

Yes. All the records that had my initials in them changed to XXX.

Because the renaming of a record also changes any values that are related
to it in other tables.

Exercise 2.5.3 Filtered Table Relations

When you use the lookup button on the Salesperson Code field do you
see all the records in the Salesperson/Purchaser table? If not, why?

No. The table filter on the table relation filtered out any records with a
Commission % <= 0.

Can you type in the value AH into the Salesperson Code field? If not,
why?

No. The filtered table relation no longer allows AH as a valid value,


because it does not exist in the filtered record set.

Exercise 2.5.4 Conditional Table Relations

When you use the lookup button on the No. field what form is displayed?
What if you change the Type field?

The table relation now depends on the Type field. Using the lookup button
when Type=Item displays the Item List form and so on.

Try changing Type to Item and looking up an item number. Now, change
Type to Resource. What happens? Is the value for No. valid?

Nothing happens!

No. The value in No. is an Item No. not a Resource No. It is invalid.
2-68 Navision Attain Objects

Now try retyping the value in the No. field after changing the Type as
described in the previous question. What error do you get?

The Resource No. ‘70000’ does not exist.

Exercise 2.6.1 Calculating the Sums Manually


Which Total Total Amount

For JR 1050.00

For MF 800.00

For PS 185.00

For ALL 2035.00

Exercise 2.6.2 Creating a FlowField

No questions here

Exercise 2.6.3 Testing your FlowField

What happened when you tried to run the table?

I received an error.

What caused the error message?

A missing Key and SumIndexField.

What do we need to change to correct the problem (hint: read the error
message very carefully)?

I need to add a key to the Sales Transaction table that has the correct
fields and a SumIndexField of Amount.

Exercise 2.6.4 Creating a SumIndexField

Were there any errors this time? Why or Why not?

No.

It found the key and SumIndexField that it needed to calculate the


FlowFields
Basic Tables 2-69

Which Total Sales

For JR 2035.00

For MF 2035.00

For PS 2035.00

Do the totals seem correct? What is suspected about them?

No.

They are all exactly the same.

Do they match any of the values from exercise 5.4.1 (your manual sums)?
Which ones do they match?

Yes.

They match the total amount for the entire table.

What seems to be wrong with your FlowField?

It is not summing the records for each Salesperson. It is summing all of the
Salespeople together.

Exercise 2.6.5 Filtering the FlowField

What happened when you tried to run the table?

I received an error.

What caused the error message?

A missing Key and SumIndexField.

What do we need to change to correct the problem (hint: read the error
message very carefully)?

I need to add a key to the Sales Transaction table that has the correct
fields and a SumIndexField of Amount.

Exercise 2.6.6 A Process for Creating a SumIndexField

Table Name: Sales Transaction

Field Name: Amount


2-70 Navision Attain Objects

Field Name 1: Salesperson Code

Were there any errors this time? Why or Why not?

No.

The SumIndexField and FlowField matched.

Exercise 2.6.7 Creating a FlowFilter

No questions here

Exercise 2.6.8 Using a FlowFilter

What happened?

An error occurred.

Why did we only get the message after we set the FlowFilter?

Until a FlowFilter is used, a special key is not required.

What is the error message that you received?

FlowField cannot be calculated. You must setup and activate a key …

Have you seen an error message like this before?

Yes. Before the SumIndexField was set up.

What is the next step that you should take to correct the problem?

Add the Type field to the key for my SumIndexField.

Exercise 2.6.9 Correcting the Problem.

Did everything work correctly that time?

Yes. It filtered the FlowFields appropriately.

Exercise 2.7.1 The NotBlank Property

What is the “name” of the record (remember that a name is the values of
the primary key fields)?

Model = ‘’, Serial No. = 0


Basic Tables 2-71

What happens if you repeat steps 2-5 above?

An error occurs saying that the record already exists.

How could we eliminate blank records being put into the table by accident?

Force the user to enter at least the primary key fields.

What happens this time?

I am forced to enter the Model. I cannot leave it blank.

What must you do to insert a new record now?

I must at least fill in a value for the Model field.

Exercise 2.7.2 The Editable Property

What happened?

The value changed to 500.There was no error.

Did the change last (if you close the table and run it again, is the value still
500 for PS)?

Yes.

What is the new sum? What was the old sum (section 5.4.1)? What is the
difference?

New: 500

Old: 185

Diff: 315

Can you identify the line that may have changed the sum?

Yes. There is a new line with an Amount of 315 for PS.

Did you enter this line? How did it get entered?

No.

When the FlowField was changed, this record must have been inserted.
2-72 Navision Attain Objects

Exercise 2.7.3 The DecimalPlaces Property

Were you able to enter the amount correctly?

No. An error occurred.

What error did you get?

The field can have a maximum of 2 decimal places.

What happened?

I was able to put in the value with all three decimal places.

What is displayed in the field if you enter the Amount 234.1 and press
Enter?

234.10

What is displayed in the field if you enter the Amount 234 and press Enter?

234.00

What is displayed in the field if you enter the Amount 234.110 and press
Enter?

234.11
Basic Tables 2-73

2.10 CHAPTER TEST

This section reviews the concepts of the chapter by asking you questions.
The answers are in the subsection Answers.

Questions

1 What two major items can you define within a table description?

2 What table property defines the default lookup form for the table?

3 What field property is used to force the user to enter a value into a
primary key field?

4 What number range can you use for new fields that you add to the
Customer table?

5 If you want to view customers in order by the city that they live in, what
would you have to change in the table description?

6 How could you change the Salesperson Code field in the Customer
table so that the user would only be able to lookup Salespeople that
have a Commission % larger than zero?

7 What type of table is the Customer table?

8 What type of table is the Item Vendor table?

9 What type of table is the Currency table?


2-74 Navision Attain Objects

10 What type of table is the Item Ledger Entry table?


Basic Tables 2-75

Answers

1 What two major items can you define within a table description?

Fields and Keys.

2 What table property defines the default lookup form for the table?

LookupFormID

3 What field property is used to force the user to enter a value into a
primary key field?

NotBlank set to Yes

4 What number range can you use for new fields that you add to the
Customer table?

50000 to 99999

5 If you want to view customers in order by the city that they live in, what
would you have to change in the table description?

Add a secondary key that contains the City field as the first field.

6 How could you change the Salesperson Code field in the Customer
table so that the user would only be able to lookup Salespeople that
have a Commission % larger than zero?

Add a table filter to the table relation property that filters the Salespeople
where Commission % > 0.

7 What type of table is the Customer table?

Master table for Sales and Receivables functional area.

8 What type of table is the Item Vendor table?

Subsidiary to the Vendor and the Item tables.

9 What type of table is the Currency table?

Supplemental to all functional areas.

10 What type of table is the Item Ledger Entry table?

Ledger for the Inventory functional area


Chapter 3.

Basic Forms

Forms are used to enter and display data. For


example, you can use a form to enter information
about new customers or to update and review
information about existing customers.

This chapter introduces the fundamental


concepts and basic tasks involved in designing
and using forms. The exercises in this chapter will
reinforce the knowledge that you will gain in this
part of the course.

This chapter contains the following sections:

What Are Forms?

Starting with a Blank Form

Other Useful Controls

Using the Form Wizard

Creating Buttons

Creating Subforms

Form Types and Characteristics

Standard Navigation

Answers to the Questions

Chapter Review
3-2 Navision Attain Objects

3.1 WHAT ARE FORMS?

After you have created tables, the next step in developing a C/SIDE
application should be to design forms. Forms are used for entering
information into database tables and for retrieving and displaying
information from database tables. It is through forms that users generate
the events that determine the flow of the application.

Forms can be used to access one table at a time, or they can combine
information from a number of different tables. A form can display
information that is calculated on the fly as the form is displayed, and it can
contain information (such as a label) that is not related to any table, or
purely decorative elements (such as bitmap pictures).

The figure below shows the components of a form and how they are
related. This and the following chapters will explore each component in
depth.

Form Description

Form Properties

Triggers

Controls

Properties

Triggers

Forms are created and edited in the Form Designer.

What Are Controls?

All information on a form is presented in controls. Controls are objects that


can display data from a database table field, the value of a C/AL
expression, bitmap pictures or static information such as a descriptive text.

Some controls are called container controls. An example is a frame. The


frame itself does not display data or information, but it can contain a
number of other controls that you want to group. A powerful container
control is the tab control. A tab control really is a number of frames or
pages that are placed on top of each other. The user can switch between
the pages by clicking the tabs that have captions. Tab controls make it
possible to group information on a form so that each page is not cluttered
with information, and it is very fast and easy to switch between pages.
Basic Forms 3-3

Another concept is control branches, which consist of a parent control and


subordinate or child controls. The best example is a text box and a label.
The child control inherits some properties from the parent, and the entire
branch can be moved together on the form.

What Are Bound and Unbound Forms and Controls?

Typically, a form is related to a database table and will be used to enter


information into the table and display information from the table. The form
is said to be bound to the table.

An unbound form is not related to a table. An example of an unbound form


is a form that is used as a menu, from which the user can choose other
forms or reports to run.

The controls on a form that is bound to a table are usually bound to fields in
the same table. There need not be a control for every field in the table, nor
do all controls on the form need to be bound to table fields – controls that
aren’t bound to fields are called unbound controls. An example is a
command button that causes the information on the form to be printed;
another is a control that contains a descriptive text. An important category
of unbound controls includes controls displaying information – based on the
underlying table or user-entered values – that is calculated as the form is
displayed.

What Are Form and Control Properties?

Properties describe how a control is placed on the form, what field it is


related to and what happens when information is entered into the field,
among other things. Different types of controls have different sets of
properties. For example, a text box, the control type that is typically used to
display the contents of a database field, has more properties than a picture
box, a control used to display bitmap pictures.

The form itself also has properties. For example, you can specify whether
the form is to be used only for displaying information or whether it will be
possible to insert new records or update existing ones.

Properties are defined on the Properties window that can be edited when
the form is opened in the Form Designer.

What Are Triggers?

Certain predefined events that happen to a form or a control cause the


3-4 Navision Attain Objects

system to execute a user-definable C/AL function---the event triggers the


function. The event and the function are together called a trigger. Form
triggers include OnOpenForm, containing statements that will be executed
when the form is opened, and OnModifyRecord, containing statements that
will be executed before the system accepts changes the user makes to a
record. Triggers are edited in the C/AL editor, which can be opened from
the Form Designer.
Basic Forms 3-5

3.2 STARTING WITH A BLANK FORM

In this section, you will learn how to create a blank form. This is not the
best way to create a form, but it will give you an appreciation for the Form
Wizard and the Field Menu (these are discussed in a later section).

Exercise 3.2.1 Creating a Blank Form

You will start by creating a blank form. There is a Wizard that helps you
create forms, but you will use it later. The steps to create a blank form are:

1 Click Tools, Object Designer.

2 In the Object Designer window, click Form.

3 Click New. C/SIDE displays the Form Wizard window.

4 Click OK to create a blank form. C/SIDE will display the Form


Designer window. When you create a blank form, the size is rather
small. You can enlarge this if you need to in later exercises.

5 Close, save, and compile the new form. Use the name ‘Blank Form’
and the ID 91100. You will be using this form in the following
exercises.

6 Run the form.


3-6 Navision Attain Objects

What is the value in the title bar of the form (this is usually the blue area at
the top of a form that has the Min, Max, and Close buttons on it)?

What happens when you click the Next button on the toolbar?

Is the form reading information from a table?

Exercise 3.2.2 Attaching a Source Table

A blank form is unbound when it is created. This means that it is not


associated with any table. In this exercise, you will associate the blank form
you created with a table and see what happens.

1 Open form 91100 (Blank Form) in the Form Designer.

2 Open the Properties window for the form.

3 Click on the SourceTable property.

4 Enter the number 18 into this property. 18 is the ID of the Customer


table. Your form is now bound to the Customer table.

5 Close, save and compile the form.

Now let’s take a look at what has changed.


Basic Forms 3-7

Run form 91100 (Blank Form) and answer the following questions.

What is the value in the title bar of the form (this is usually the blue area at
the top of a form that has the Min, Max, and Close buttons on it)?

What happens when you click the Next button on the toolbar?

Is the form reading information from the source table?

Exercise 3.2.3 Adding Simples Controls

In this exercise, you will add a text box, label and a checkbox to your blank
form. These are the most common controls that you see on a form.

Adding a Text Box

1 Open form 91100 (Blank Form) in the Form Designer.

2 Click on the Toolbox button on the toolbar (or View, Toolbox). The
Toolbox window appears.

3 Hold your mouse over each button on the Toolbox window for a few
seconds. This will show you the Tool Tip for that button. The Tool Tip
displays the name of the control that the button represents.

4 Click on the Text Box button on the Toolbox window. This selects this
control type (the button stays down). To unselect this control type, you
can click on the Arrow button at the top left of the Toolbox window.
3-8 Navision Attain Objects

5 With the Text Box button selected, move the cursor (mouse pointer)
over the blank form. Your cursor should change to the cross hairs and
a box.

6 Click somewhere in the middle of the form. Notice that where you click
is where the upper left corner of the Text Box is located. If you drag
the mouse with the mouse button still down, you will change the size
of the Text Box as you are creating it. This is usually not useful.

You now have a Text Box on your form. What information will it display?

Try running the form by clicking File, Run. What happens?

Binding the Text Box

The Text Box control must be bound to a field or other data element (this
could be anything that returns a valid value: variable, function, or other
expression).

To bind the Text Box control, you must set a property:

1 Click on the Text Box control to select it.

2 Open the Properties window.

3 Change the SourceExpr property to “No.” (including the double


Basic Forms 3-9

quotes).

4 Close, save and compile the form.

5 Run the form and test your new Text Box by moving to the next,
previous, first or last record.

Adding a Label

There is only one problem that someone using your very simple form might
have. The user may not know what is being displayed. To help your user,
you will add a label that describes the field on the form.

1 In the Toolbox window, click Label (remember to use the Tool Tips to
help you find the right button).

2 Move the cursor over the form and click somewhere to the left of the
Text Box control that you added.

3 Open the Properties window for the label.

4 Change the Caption property to No..

5 Close, save and compile the form.

6 Run the form and test your new Text Box by moving to the next,
previous, first or last record. The label lets you know what field you are
looking at.

Adding a CheckBox

1 In the Toolbox window, click Checkbox.


3-10 Navision Attain Objects

2 With the Checkbox button selected, move the cursor (mouse pointer)
over the blank form.

3 Click somewhere in the middle of the form below the other controls.
Notice that where you click is where the upper left corner of the
Checkbox is located.

4 Like the Text Box, the Checkbox control must be bound to a field or
other expression. For a Checkbox to work correctly, however, the
expression or field that it is bound to must return a Boolean value (true
or false). A check in the box represents true, and an empty box
represents false.

5 Open the Properties window.

6 Change the SourceExpr property to Blocked.

7 A Checkbox has a built-in label. So, change the Caption property also
to Blocked.

8 You will have to change the ShowCaption property to Yes and


perhaps expand the size of the checkbox to see the caption. Notice
that the built in label for a Checkbox appears on the right side of the
checkbox. This can be changed with another property (you can
experiment to find out which one).

9 Close, save, and compile the form.

10 Run the form and test your new Checkbox by moving to the next,
previous, first or last record. You will also want to check and uncheck
the box.
Basic Forms 3-11

Exercise 3.2.4 Using Add Label and Lock

There are two very useful options on the bottom of the Toolbox window
that can help you quickly design your forms. The first is the Add Label
option. It allows you to attach a label automatically when you put another
type of control onto the form like a Text Box. The second is the Lock option.
It allows you to quickly add more than one control at a time.

Using Add Label

1 Open form 91100 (Blank Form) in the Form Designer.

2 Click on the Toolbox button on the toolbar (or View, Toolbox). The
Toolbox window appears.

3 Click on the Add Label button (bottom right). Notice that this button
stays down. To unselect it (bring it back up) you can click it again. It
will stay down until you unselect it or leave the Form Designer.

4 Click on the Text Box button. Notice that the Add Label button is still
selected.

5 Move the cursor over to the form (under the other controls) and click
to put the Text Box on the form.

What else was put on the form?

What happens when you move the Text Box?

What happens when you move the Label?


3-12 Navision Attain Objects

How can you move just the Text Box (hint: look for the hand cursor)?

What happens if you click on the Checkbox button and then click on the
form?

6 Delete the controls that you added for this exercise.

7 Close, save and compile the form.

Using Lock

1 Open form 91100 (Blank Form) in the Form Designer.

2 Open the Toolbox.

3 Click on the Lock button (bottom left). Notice that this button stays
down. To unselect it (bring it back up) you can click it again. It will stay
down until you unselect it or leave the Form Designer.

4 Click on the Text Box button. Notice that the Lock button is still
selected.

5 Move the cursor over to the form (under the other controls) and click
to put the Text Box on the form.

6 Move the cursor down and click again.

7 Move the cursor down and click again.

8 Move the cursor down and click again.


Basic Forms 3-13

How many Text Box controls did you add?

Can you move any of the controls with the Lock button selected?

9 Delete the controls that you added for this exercise by selecting them
one at a time and pressing the DELETE key or by using a Marquee
selection to select them all and then pressing the DELETE key. For
more information about selecting controls, see the manual Application
Designer’s Guide.

10 Close, save and compile the form.

Using Add Label and Lock

Design the form one more time and use both the Add Label button and the
Lock button to add Text Boxes. Experiment with both of these until you are
comfortable.

Remember to remove any unbound controls before trying to save the form.

Multilanguage Functionality

When adding an unbound control to the form, populate the CaptionML


property as described previously in Basic Tables. If the new control is an
Option button populate the OptionCaptionML as well. If you have created a
new field in the table and are adding it to the form, the CaptionML will not
3-14 Navision Attain Objects

be shown until the form is compiled. New Forms will need the Form
CaptionML populated also.
Basic Forms 3-15

3.3 OTHER USEFUL CONTROLS

In this section, you will create and use various types of controls. You will
start again with a blank form.

For some of these exercises, you will need to create a new item record.
The following will guide you to creating that record.

1 Open the Item Card window from the Inventory menu.

2 Press F3 to insert a new record.

3 In the No. field, enter 1111.

4 In the Description field, enter My Test Item.

5 Close the Item Card.

6 When instructed to find Item 1000, you should find the item you just
created.

Exercise 3.3.1 Adding Container Controls

In this exercise, you will add container controls to your blank form. You get
to use the Tab, Frame, and the Table Box controls.

1 Create a blank form as in exercise 3.2.1. Use the name ‘Blank Form 2’
and the ID 91200.

2 Follow the steps in exercise 3.2.2 to set the SourceTable to Item (the
Customer table is not useful for some of the exercises).

3 Open form 91200 in the Form Designer.


3-16 Navision Attain Objects

Using a Tab Control

1 Open the Toolbox.

2 Click the Tab Control button.

3 Move the cursor over the top left area of the form.

4 Click to create the Tab control. Notice that it has only one tab. The
name of the first tab is General. This name is a standard for forms that
have Tab controls.

To add more tabs to a Tab Control:

1 Click the first tab on the Tab Control (any tab will do). This may select
the Tab control or it may simply change to that tab.

2 To assure that the Tab control is selected, click the first tab again.

3 With the Tab control selected, open the Properties window.

4 Click on the PageNames property. Notice that the current value is


<General> (the name of the first and only tab). The PageNames
property is a comma-separated list of tab names. To add a tab, you
simply add to the list. (You can press the F2 function key twice to get
to the end of a selected field.)

5 Change the PageNames Property to read General,Test,Frame,Table


Box. There are no spaces after the commas.
Basic Forms 3-17

What happened to the Tab control?

Adding Controls to a Tab

1 Click the Tab that you want to add the control to. In this case, click on
the Test tab.

2 Select the control on the Toolbox window. Select a Label control.

3 Click on the Tab where you want the control to be. You can move the
control if you need to.

What happens if you click on the General tab and back to the Test tab?
3-18 Navision Attain Objects

4 Edit the PageNames property of the Tab control so that it looks like
General,Frame,Table Box. Where is the label control now?

5 Move the label control to the bottom of the form (off of the Tab
control). What happens when you change to the General tab and back
now?

6 Click on the General tab and move the label from the bottom of the
form to the middle of the page for the General tab. What happens
when you change to the Frame tab and back?

Adding a Frame Control

A Frame control is similar to the page of a Tab control. It holds other


controls and when you move the frame, the controls stay with it.

1 Click on the Frame tab of the Tab control.

2 In the Toolbox window, select the Frame button.

3 Click in the middle of the page for the Frame tab. A frame should be
created.

4 Change the Caption property of the Frame control to Test Frame.


Basic Forms 3-19

5 Add several label controls to the Frame. Remember to drop the


controls inside the frame.

What happens if you move the frame?

What happens if you delete the frame?

Adding a TableBox Control

A TableBox is a container control that contains bound controls. It allows the


form to display more than one record at a time.

1 Click the Table Box tab of the Tab control.

2 On the Toolbox window, select the TableBox control.

3 Click in the middle of the tab to create the TableBox. You may want to
move it to the upper left corner. Notice that the TableBox is empty.
Remember that it is a container control. We still need to add other
controls to it.
3-20 Navision Attain Objects

The most common control that you see in a TableBox is a Text Box.

4 On the Toolbox window, select the Text Box control.

5 Click on the TableBox. The Text Box control becomes a column and a
Label control is added to the top for a column heading.

6 Change the SourceExpr property of the Text Box control (column) to


“No.” (including the double quotes).

7 Close, save and compile the form.

8 Run the form. What is displayed in the TableBox?


Basic Forms 3-21

What happens to the title bar of the form if you click on another row in the
TableBox?

What happens if you maximize the form or simply make it bigger?

Autosizing Controls

It would be better if the tab control grew with the form. The TableBox
should also grow with the form. We will adjust the “glue” properties of the
controls to allow this.

1 Open form 91200 in the Form Designer.

2 Select the Tab Control by clicking on the General tab twice.

3 Open the Properties window.

4 Change the HorzGlue property to Both.

5 Change the VertGlue property to Both.

6 Select the TableBox control by clicking on the TableBox tab and then
clicking the upper left gray box in the TableBox control.

7 Open the Properties window.

8 Change the HorzGlue property to Both.

9 Change the VertGlue property to Both.

10 Close, save and compile the form.

11 Run the form. What happens now when you resize the form by making
it bigger?

Exercise 3.3.2 Displaying Options

Option fields can be displayed to the user in two different ways. You can
use a Text Box control (which can display almost anything) or you can use
option buttons (also known as radio buttons). In this exercise, you will
explore both.
3-22 Navision Attain Objects

Using a Text Box

1 Open form 91200 in the Form Designer.

2 Add a Text Box with an attached label to the General tab.

3 Change the SourceExpr property of the Text Box to Costing Method.


The Costing Method field is an option field in the Item table.

4 Close, save, and compile the form.

5 Run the form.

What type of button is in the Text Box?

What happens when you click the button?

Using Option Buttons

1 Open form 91200 in the Form Designer.

2 In the Toolbox window, click the Lock button to select it.

3 In the Toolbox window, click the Option button.

4 On the General tab, click to create an Option button.


Basic Forms 3-23

5 Move down and click again to create another Option button.

6 Move down and click again to create the last Option button. There are
five option values for the Costing Method field. You will only allow the
user to access three of the values. That is why you need three Option
buttons. Each Option button represents one value of the Costing
Method field.

7 In the Toolbox window, click the Lock button to unselect it.

8 For each Option button, change the SourceExpr property to “Costing


Method”.

9 For the first Option button, change the OptionValue property to 0.

10 For the first Option button, change the Caption property to FIFO.

11 For the second Option button, change the OptionValue property to 1.

12 For the second Option button, change the Caption property to LIFO.

13 For the third Option button, change the OptionValue property to 2.

14 For the third Option button, change the Caption property to Specific.

15 Close, save, and compile the form.

16 Run the form and find item 1000.

How many of the Option buttons are selected?


3-24 Navision Attain Objects

What happens if you try to select another one?

What happens if you change the Text Box that is bound to the Costing
Method field to Specific?

What happens if you change the Text Box that is bound to the Costing
Method field to Average?

Exercise 3.3.3 Displaying Progress Indicators

For this exercise, you will create a way for the user to easily see the
percentage of profit that they make on each item. You will use a vertical
progress bar that goes from 0 to 100.

1 Open form 91200 in the Form Designer.

2 In the Toolbox window, click on the Indicator button.

3 Click the General tab to create an indicator control. By default, the


indicator starts on the left and increase to the right. Yours will start at
the bottom with zero and increase up to the top (100).

4 Change the Orientation property of the Indicator control to Bottom.

5 Change the MinValue property to 0.


Basic Forms 3-25

6 Change the MaxValue property to 100.

7 Change the SourceExpr property to “Profit %”.

8 Increase the height of the Indicator control by dragging the top edge.

9 Close, save, and compile the form.

10 Run the form.

Use the Next button to look at many different records. What range of values
did you notice?

What happens if you change the MaxValue property to 1000 and run the
form again?

Exercise 3.3.4 Displaying BLOB Fields (Pictures)

BLOB fields are used primarily to store pictures. Some items in the Item
table have pictures. You will add a control to your form to display the
picture to the user.

1 Open form 91200 in the Form Designer.

2 Select the Tab Control by clicking on the General tab twice.

3 Add a tab to the Tab control called Picture. Make sure this is the last
tab on the control.
3-26 Navision Attain Objects

4 Click the Picture tab.

5 In the Toolbox window, click the PictureBox button.

6 Click in the middle of the tab to create the PictureBox control. Don’t
worry about the size. The default size will work fine for this example.

7 Change the SourceExpr property of the PictureBox control to Picture.

8 Close, save and compile the form.

9 Run the form.

Use the Next button to look at many different records. List some of the
items that have pictures?
Basic Forms 3-27

3.4 USING THE FORM WIZARD

In this section, you will learn easier ways of creating and modifying forms.
Always keep in mind what you learned in the previous sections so that you
understand what is really being done for you.

The form wizard can create two different types of forms – Card forms and
Tabular forms.

Exercise 3.4.1 Card Forms

A card form is a form that displays one record at a time to the user. It
usually has a tab control, and the first tab is normally called ‘General’. In
this exercise, you will create a card form using the wizard.

Starting the Wizard

1 Open the Object Designer and click the Form button.

2 Click New and C/SIDE displays the New Form window.

3 Enter 18 in the Table field. You are creating a new Customer Card
form.

4 Click ‘Create a form using wizard’.

5 Click ‘Card-Type Form’ in the list.

6 Click OK to start the Card-Type Wizard.

The Card-Type Wizard

Anytime during the creation of the form in the Wizard, you can press
Preview on the bottom of the Wizard to view what you will be creating.
3-28 Navision Attain Objects

1 Should the Form contain tabs?

2 Leave Yes selected. Notice that the first tab is called General by
default.

3 Click in the empty line under General and enter Second Tab.

4 Click Next.

Which fields from the Customer table do you want on the tabs?

5 Click on the Second Tab tab. Notice that the form has both of the tabs
that you requested.

6 Click on the General Tab.

7 Double click the following fields: No., Name, Address and City.
These fields are moved onto the General tab.

8 Click on the Second Tab tab. Notice the Field Order list is empty for
this tab.

9 Double click the following fields: Global Dimension 1 Code, Territory


Code, Global Dimension 2 Code.

10 Click Finish to end the wizard and open the newly created form in the
Form Designer. The form has not been saved yet.

11 Close, save and compile the form with the ID 91300 and the Name My
Customer Card.

12 Run the form and test your tabs and fields.


Basic Forms 3-29

Exercise 3.4.2 Tabular Forms

A tabular form is a form that displays many records at a time to the user. It
usually has a Tablebox control. In this exercise, you will create a tabular
form using the wizard.

Starting the Wizard

1 Open the Object Designer and click the Form button.

2 Click New. C/SIDE will display the New Form window.

3 Enter 18 in the Table field. You are creating a new Customer List
form.

4 Click ‘Create a form using wizard’.

5 Click ‘Tabular-Type Form’ in the list.

6 Click OK to start the Tabular-Type Wizard.

The Tabular-Type Wizard

Anytime during the creation of the form in the Wizard, you can press
Preview at the bottom of the Wizard to view what you are creating. Notice
that there is only one screen in this wizard. When you are finished in this
screen, you are done with the wizard.
3-30 Navision Attain Objects

1 Which fields from the Customer table do you want on your form?

2 Double click the following fields: No., Name, Address and City.

3 Click Finish to end the wizard and open the newly created form in the
Form Designer. The form has not been saved yet.

4 Close, save and compile the form with the ID 91301 and the Name My
Customer List.

5 Run the form and test your fields.

Unlike the real Customer List form, this form allows the user to change the
values. This is not desirable because a list form is used for searching and
selecting records. You need to change the form so that it is not editable.
You could change every control, but that would still allow deletions and
inserts.

1 Open form 91301 in the Form Designer.

2 Open the Properties window for the form.


Basic Forms 3-31

3 Change the Editable property of the form to No.

4 Close, save and compile the form.

5 Run the form.

6 Click the Name field and enter your name.

What happens?

Why is this desirable to a user?

Exercise 3.4.3 Using the Field Menu

In this exercise, you will add fields to your card form and your list form.

Note

The Field Menu can be used to add fields to any bound form, whether you
used the wizard to create the form or not.

Adding Fields to a Card Form

1 Open form 91300 in the Form Designer.

2 On the toolbar, click the Field Menu button to open the Field Menu
window.

3 Find the Balance field in the Field Menu window.


3-32 Navision Attain Objects

4 Click the gray box beside the Balance field to select the field (it should
be highlighted in blue).

5 Move the mouse over the form where you want the field to be.

6 Click to create a Text Box for the field. The SourceExpr property is
already set for you.

7 Close, save, and compile the form.

8 Run the form.

Does the field work properly?

What else got placed on the form with the Text Box?

Adding Fields to a Tabular Form

1 Open form 91301 in the Form Designer.

2 On the toolbar, click the Field Menu button to open the Field Menu
window.

3 Find the Balance field in the Field Menu window.

4 Click the gray box beside the Balance field to select the field (it should
be highlighted in blue).

5 Move the mouse over the Tablebox where you want the new column
to be.

6 Click to create a new column for the field. The SourceExpr property is
already set for you.
Basic Forms 3-33

7 Close, save and compile the form.

8 Run the form.

Does the field work properly?

What was the column heading?

Do you think that most users will need to see the Balance field on this
form?

Exercise 3.4.4 Making Columns Invisible on a Tabular Form

Because most users don’t need to see the customer’s balance, the column
should be made invisible on the List form by default. However, every user
should be able to add it.

In this exercise, you will change the List form so that it accommodates the
requirements mentioned above.

1 Open form 91301 in the Form Designer.

2 Open the Properties window for the Balance field column.

3 Change the Visible property of the Text Box to No.

4 Close, save and compile the form.


3-34 Navision Attain Objects

5 Run the form.

Can you see the column?

6 Click View, Show Column. Is the Balance field listed? Is the Net
Change field listed?

Why is the Balance field listed and the Net Change field not?

7 Check the box next to the Balance field and Click OK. Is the Balance
field shown now?

What happens if you close the form and run it again?


Basic Forms 3-35

3.5 CREATING BUTTONS

In this section, you will learn about the most important control that you will
have to add to almost all forms (the wizard won’t do this for you). This
control is the button.

You will explore the main two types of buttons – Command Buttons and
Menu Buttons.

Exercise 3.5.1 Creating Command Buttons

In this exercise, you will create a command button that closes the form.

1 Open form 91300 in the Form Designer.

2 Open the Toolbox window.

3 Click Command Button.

4 Move the mouse over the bottom right of the form (to the left of the
Help button).

5 Click to create the Command Button. On standard forms, buttons go in


the bottom right corner.

6 Open the Properties window for the button.

7 Change the PushAction property of the button to OK (not LookupOK).


This tells the button to be an OK button. OK buttons close the form
when clicked. PushAction must be set on any button that you want to
work without code.

8 Close, save and compile the form.

9 Run the form.


3-36 Navision Attain Objects

What caption does the button have?

What happens when you click the button?

10 Run the form again. Resize the form slowly. What happens to your
new button?

What happened to the Help button?

What caused them to act differently?

11 Change the HorzGlue and VertGlue properties of your button to match


those of the Help button.

12 Test the form again by resizing it.

What happens to your new button?

Exercise 3.5.2 The RunObject PushAction

In this exercise, you create a push button that runs another form.

1 Open form 91301 in the Form Designer.

2 Add a Command Button (see previous exercise) next to the OK


Basic Forms 3-37

button.

3 Change the caption of the button to ‘Card’. Don’t forget to change the
glue properties as well.

4 Change the RunObject property to ‘form 91300’ (without the quotes).


You can use the lookup button to find form 91300 as well. Entering the
values, is usually faster.

5 Close, save and compile the form.

6 Run the form.

Where is the button? Where are the OK and Cancel buttons?

What happens when you click the button?

What did you neglect to set?

7 Change the PushAction property of the button to RunObject. Now, the


button will perform the action. A PushAction of <0> will cause the
button to do nothing (except fire its OnPush trigger). You may also
want to move your Card button next to the Help button.
3-38 Navision Attain Objects

8 Run the form again. What happens this time when you click the Card
button?

9 Close the card form. Select customer 50000 on the list form. Click the
Card button. Which customer is displayed on the card form?

Exercise 3.5.3 Linking Forms

In this exercise, you will change the Card button so that it opens the card
form with the record that is selected on the list form. This is called linking.

1 Open form 91301 in the Form Designer.

2 Open the Properties window for the Card button. Just below the
RunObject property are the RunForm properties. These properties
allow you to control the form that the button runs.

3 Change the RunFormLink property to No.=FIELD(No.). You can also


use the assist-edit button to bring up the Table Filter dialog to assist
you.

4 Close, save and compile the form.

5 Run the form.

What happens when you click the Card button when customer 50000 is
selected?

What happens if you close the card form, select another customer and click
the Card button again?
Basic Forms 3-39

Notice that while the card form is open, you can click back on the list form
and choose another record. What happens to the card form when you
change the list form in this way?

6 Design the form and change the RunFormLinkType property of the


Card button to OnUpdate.

7 Save your changes and run the form. Now, what happens when you
change the list form while the card form is still open?

Exercise 3.5.4 Creating Menu Buttons

Menu buttons are containers for menu items. A menu item is almost
identical to a command button (they share many properties).

In this exercise, you will create a menu button.

1 Open form 91301 in the Form Designer.

2 Move the OK and Cancel buttons to the left.

3 In the Toolbox window, click Menu Button.

4 Click on the form next to the Card button.

5 Change the caption of the menu button to Customer. Most card and
list forms contain a menu button with the name of the table.
3-40 Navision Attain Objects

6 Make sure to change the glue properties on the button as you did with
the other buttons.

7 Close, save and compile the form.

8 Run the form.

What happens when you click the new menu button?

Exercise 3.5.5 Creating Menu Items

In this exercise, you will add menu items to your menu button.

1 Open form 91301 in the Form Designer.

2 Click on the Customer menu button to select it.

3 Click View, Menu Items to open the Menu Designer

4 In the Caption field in the first empty line, enter the word Card.

5 Instead of entering the rest of the values on the line, open the
Properties window for the menu item.

6 Change the PushAction property to RunObject.


Basic Forms 3-41

7 Change the RunObject property to Form 91300.

8 Change the RunFormLink property to No.=FIELD(No.). You can also


use the assist-edit button to open the Filter window and set the values
there.

9 Change the RunFormLinkType property to OnUpdate.

10 Change the ShortCutKey property to Shift+F5.

11 Close the Menu Designer.

12 Close, save and compile the form.

13 Run the form.

What happens when you click the menu button now?

What happens when you click the Card menu item?

What happens when you press Shift+F5?

Exercise 3.5.6 The LookupTable PushAction

In this exercise, you will explore a very special PushAction called


LookupTable.

1 Open form 91300 in the Form Designer.

2 Add a menu button to the form with the caption Customer as in one of
the previous exercises.

3 Add a menu item to the menu button that has a caption of List.

4 Change the ShortCutKey of the menu item to F5 and the PushAction


to LookupTable. This action brings up the default lookup form for the
form’s source table.
3-42 Navision Attain Objects

5 Close, save and compile the form.

6 Run the form.

What form comes up when you press the F5 function key?

Why does that form come up and not your customer list form?

7 Open table 18 in the Table Designer and change the LookupFormID


property of the table to 91301. Run your card form again. Now what
form comes up when you press the F5 function key?
Basic Forms 3-43

3.6 CREATING SUBFORMS

In this section, you will learn how to display information from another table
on a form (not the source table of the form). One way to accomplish this is
to display another form within the first form. This is called a subform. Here
you will explore the subform control.

You will build two forms that come together to show the customer records
and the customer comments on one form.

Exercise 3.6.1 Creating the Main Form

In this exercise, you will create the main form. It will display customer
information and include a subform control that displays comments for the
customer.

1 Open the Object Designer window and click Form.

2 Click New. C/SIDE displays the New Form window.

3 Create a card form using the wizard that contains the customer
number, name, address, city, state and zip code on one tab named
General. See exercise 3.3 for more information on using the wizard.

4 Once the form wizard is done, save and compile the form with the ID
91500 and the name Customer Comment.

5 Make room for the Subform control by making the form larger (not
wider) and moving the Help button down to the bottom right corner.
There should be almost as much room on the form for the Subform
control as there is for the Tab control.

6 Create a Subform control on the form from the Toolbox window. The
control should be positioned just below the tab control and should be
exactly the same width. Adjust the height of the subform control to
take up the available space.

7 Open the Properties window for the Subform control and write down
the Height and Width properties.

Height ____________________

Width _____________________
3-44 Navision Attain Objects

8 Close, save and compile the form.

9 Run the form.

What appears where the subform control is?

Exercise 3.6.2 Creating the Subform

In this exercise, you will create the form that displays the comment lines for
the customer. It will be a worksheet form that fits into the subform control
on the Customer Comment form.

1 In the Object Designer window, click Form.

2 Click New. C/SIDE displays the New Form window.

3 Create a tabular form using the wizard that contains the Table Name,
No., Line No., Date and Comment fields from the Comment Line
table (the Code field is not needed). See exercise 3.3 for more
information on using the wizard.

4 To make this into a sub form, you must delete all buttons (OK, Cancel,
and Help). You must also move the table box into the upper left corner
and make the form the same size as the table box control.
Basic Forms 3-45

5 Close, save and compile the form with the ID 91501 and the name
Customer Comment Subform.

6 Run the form.

7 Enter the following records:

Table No. Line Date Comment


Name No.

Customer 10000 10000 9/10/01 Cust. 10000 comment 1

Customer 10000 20000 9/11/01 Cust. 10000 comment 2

Customer 20000 10000 10/9/01 Cust. 20000 comment 1

Customer 30000 10000 10/10/01 Cust. 30000 comment 1

What property of the form could you use to automatically fill in the Line No.
field for you?

What purpose does the Table Name field serve?

Exercise 3.6.3 Adding the Subform to the Main Form

In this exercise, you will add the subform to the main form by setting up the
subform control.

1 Open form, 91500 in the Form Designer.

2 Click on the Subform control to select it.


3-46 Navision Attain Objects

3 Open the Properties window.

4 Change the SubFormID property to 91501.

5 Close, save and compile the form.

6 Run the form.

Now, what appears in the spot where the subform control is?

Does the Customer Comment Subform fit into the subform control perfectly
(is it lined up with the tab control)?

Why is there a box around the subform?

What happens when you resize the form by making it wider?

What happens when you resize the form by making it taller?


Basic Forms 3-47

What records show up in the subform when you change to a new customer
on the main form?

Here is a list of the things that you need to do to finish this combination of
forms:

1 Correct the sizing problems.

2 Change the VertGlue property of the Tab control to Top.

3 Change the VertGlue property and the HorzGlue property of the


subform control to Both.

4 Correct the appearance of the subform in the subform control.

5 Change the Border property of the subform control to None.

6 Change the Width and Height properties of the Tablebox control (on
the subform) to the values that you wrote down earlier.

7 Display the records in the subform that match the customer record in
the main form.

8 Change the SubFormLink property of the subform control to Table


Name=CONST(Customer),No.=FIELD(No.). You must set the Table
Name to Customer, so that only customer comments will appear on
the form.

9 Remove unneeded fields from the subform. It is dangerous to show


the user the Table Name, No. and Line No. fields. The form is
automatically filling in these values, and the user must not be allowed
to change them.

10 Change the AutoSplitKey property of the subform to Yes.

11 Delete the Table Name, No. and Line No. fields from the subform.

12 Save, compile and test these two forms again.

Are there any other problems with your forms?

Can you insert a new customer?


3-48 Navision Attain Objects

Can you add comments to that new customer?

What happens when you change to another customer?


Basic Forms 3-49

3.7 FORM TYPES AND CHARACTERISTICS

This section describes the types of windows that the user sees in C/SIDE.
It then describes the types of forms that you will create in your applications
and gives examples and characteristics of each.

Types of Windows in C/SIDE

There are five basic kinds of windows in C/SIDE, the programming


environment for Navision Attain.

Dialogs

These are simple windows that display information and whose only
responses consist of pressing a button, whether it is OK, Cancel, Yes, No
and so on. These are generated by C/AL functions such as ERROR,
MESSAGE, TESTFIELD, CONFIRM and so on, or are created by the
programmer using a variable of type Dialog. They are not associated with
Form Objects.

Request Panels

These are found only within Report Objects and are not associated with
Form Objects.

Unbound Forms

These are Form Objects that are not associated with a table. They, like
Request Panels, are used when a few questions need to be asked of a
user in order to continue processing.

One-Record Forms

These are Form Objects that are associated with a table. They let the user
see and possibly edit only one record from one table at a time. An example
of this would be a Card Form.

Multi-Record Forms

These are Form Objects that are associated with a table. They let the user
see multiple records from one table at once and possibly edit them.
Examples of these include Tabular Forms, TrendScape Forms and Matrix
Forms.
3-50 Navision Attain Objects

Our Focus

The forms that make up the Building Blocks of Attain are those Form
Objects that are associated with tables (the last two listed above). While
important, the other forms and windows are not covered in this section.

Why is This Important?

Note that while C/SIDE lets you create forms of many kinds with many
different looks and methods of operation, the Navision Attain application
only uses a few of the possibilities. This is to provide a consistent look and
feel to the application.

It is strongly recommended that for ease of use and for consistency, you
also follow this policy for all modifications to Navision Attain and for any
application that interfaces with it. All of the following descriptions assume
full use of the Navision Attain standards.

Types of Forms and Examples

There are several types of standard forms in Navision Attain. Below is a


table with the most common types of forms and some examples of each. A
more detailed description of each type appears in the following sections.

Understanding these standards regarding the forms within Navision Attain


will give you the ability to understand areas of the application with just a
superficial look at the objects.

Type One Record/Multi-Record Examples

Card Form One Record Customer Card, Vendor


Card, Item Card

Statistics One Record Customer Statistics,


Form Vendor Statistics,
Employee Statistics

Tabular Form Multi-Record Currencies, Payment


Terms

List Form Multi-Record Customer List, Item List,


Item Ledger Entries

Worksheet Multi-Record General Journal, Cash


Form Receipts Journal, Item
Transfer Journal
Basic Forms 3-51

Type One Record/Multi-Record Examples

Header/Line Both (actually two forms) Sales Invoice, Posted


Form Purchase Credit Memo,
Finance Charge Memo

Setup Form One Record General Ledger Setup,


Company Information,
Sales & Receivables
Setup

Card Form Characteristics

A Card form lets the user view and edit one record at a time in a table. It is
used when there are too many fields, to view them all conveniently on only
one line. Card forms always have tabs (like index tabs) across the top
edge, with which the user can select different groups of fields to display.

Even if there are few fields, there is at least one General tab, which is
always first.

The table's Primary Key field is always the first field in the General tab. In
tables that use Card forms, there is only one field in the Primary Key.

Naming Card Forms

Card forms are named with the name of the table they are associated with,
followed by the word "Card".

For example, the card form associated with the Customer table is called the
Customer Card. Card Forms also have at least one Menu Button at the
bottom named with the name of the table that provides ways of getting to
related information.

Statistics Form Characteristics

A Statistics form is a one-record form that lets the user view but not edit
information. It usually contains FlowFields, which lets the user drill down to
get to more information. Usually, it also contains calculated or derived
information contained in variables, which cannot be drilled down.

Statistics Forms can also contain tabs, in order to help organize the
information.

The table's Primary Key is displayed only in the form's title bar.
3-52 Navision Attain Objects

Naming Statistics Forms

Statistics forms are named with the name of the table with which they are
associated, followed by the word "Statistics".

For example, the statistics form associated with the Customer table is
called Customer Statistics.

Entry Statistics forms are a special version of the statistics form. They are
named with the name of the table they are associated with, followed by the
words "Entry Statistics". For example, Customer Entry Statistics.

Tabular Form Characteristics

A Tabular form is a multi-record form that lets the user view multiple
records from a table and edit them. Each record is displayed as a single
row in the tabular form and each field is displayed as a column forming a
spreadsheet-like table within the form itself.

The Primary Key of the associated table is displayed in the left-most


column. If there are multiple fields in the Primary Key, they display in order
of their significance in the columns, starting from the left.

Naming Tabular Forms

Tabular forms are named with the plural of the name of the table with which
they are associated.

For example, the Tabular Form associated with the Country table is called
Countries.

In the case of associated tables that have multiple fields in the Primary
Key, the name can be different. For example, the Tabular Form associated
with the General Posting Setup table is called General Posting Setup.

List Form Characteristics

A List form is a multi-record form that lets the user view multiple records
from a table at once, but not edit them. It uses the same rows-and-columns
look as the Tabular Form.

The Primary Key field(s) of the associated table is (are) displayed in the
left-most column.
Basic Forms 3-53

Naming List Forms

List Forms are named with the name of the table with which they are
associated, followed by the word "List". For example, the list form
associated with the Customer table is called Customer List.

The "Specialized" Ledger Form

A more specialized version of the List Form is the Ledger Form. These are
used only for Ledger Entry tables. They differ from ordinary List Forms, in
that even though users cannot insert or delete records, they can sometimes
edit a small number of the fields.

Also, the Primary Key, always an integer named "Entry No.", is displayed in
the right-most column rather than the left-most column.

Finally, the Ledger Form is named with the plural of the name of the
associated table. For example, the Ledger Form associated with the
Customer Ledger Entry table is called Customer Ledger Entries.

Worksheet Form Characteristics

A Worksheet form is a specialized version of the Tabular Form, a multi-


record form that lets the user view multiple records from a table and edit
them. The difference is that when the user inserts a new record, the record
does not jump to another position within the form, but instead stays in the
same order as the user inserted it.

This is done using the AutoSplitKey property of the form, combined with an
integer as the last field in the table's Primary Key.

The Primary Key fields of the associated table do not display on the
Worksheet Form.

Naming Worksheet Forms

Worksheet forms are named in accordance with the purpose of the


associated table, as covered later in this section. One example is a Journal
Table. In this case, the name of the worksheet form will end with the word
"Journal".

Header/Line Form Characteristics

Many forms within Navision Attain have characteristics of both a card form
and a tabular form, for example the Sales Invoice form.
3-54 Navision Attain Objects

The fields that are common to the entire invoice are located on a card-like
form with tabs, showing one invoice at a time. However, the invoice lines
display in a table-like section of the form, where multiple invoice lines (from
the same invoice) can be viewed at the same time and edited. These are
called "Header/Line" forms.

Header/Line forms are, in fact, two separate forms associated with two
different tables. The main form is a Card Form associated with a table. The
main form has a sub-form control. A Worksheet Form is displayed within
the sub-form control that is associated with a different table, a table that is
"subsidiary" to the first (you'll learn more later). The sub-form control
handles the linkage between the two forms.

Naming Header/Line Forms

In many cases, a Header/Line form will represent a Document.

In the example above, the Sales Invoice form, the name of the form will be
the name of the Document that it represents. In other cases, the name of
the form will be whatever the name of the main form would have been
without the sub-form.

These situations are described in more detail when we discuss the Table
building blocks.

Setup Form Characteristics

A Setup form is a one-record form that lets the user view and edit the one
and only one record in a setup table. The user is not allowed to insert or
delete this record using this form. Since there are many fields, these forms
contain tabs (like index tabs) across the top edge to organize the
information.

Since there is only one record, the Primary Key does not display anywhere
on this form.

Naming Setup Forms

Setup forms are named with the name of the table they are associated
with. For example, the setup form associated with the General Ledger
Setup table is called General Ledger Setup.
Basic Forms 3-55

Menu Form Characteristics

A Menu form is a non-bound form (not related to any table) that lets the
user access many of the other form types for a functional area from the
main menu.

The form usually consists of command buttons or menu buttons. However,


the appearance of the buttons is usually not what you would expect. The
buttons properties change so that they look basically like labels with small
circles or triangles in front of the caption. The buttons still have the same
behavior as normal buttons. The only difference is their appearance.

Naming Menu Forms

Menu forms are named with the name of the functional area they are
associated with plus the word “Menu”. For example, the menu form
associated with the General Ledger functional area is called General
Ledger Menu.

Other Multi-Record Forms

There are other forms that let users view and/or edit multiple records at the
same time. These include TrendScape forms and Matrix forms. These
forms allow great functionality within Navision Attain, but like a patio on a
house, they do not impact the main architecture of the system.
3-56 Navision Attain Objects

3.8 STANDARD NAVIGATION

This section is here to describe the normal ways that a user can go to one
form from another. We described the mechanics of this in the previous
section Extending the Functionality of Your Forms.

Here we will simply mention the standard navigation that must be provided
for consistency throughout the application.

Card and List Forms

Most master tables will have both a card and a list form. Since both of
these forms access the same table, there are many standards concerning
what each form must do.

• The user must be able to view and edit one record at a time on the
card form.

• The user must be able to view (not edit) all records on the list form. By
making this form non-editable, the user can begin a search by typing in
a particular column.

• The user must be able to bring up the list form from the card form in
the following ways – F5, List menu item (on the menu button that has
the same name as the table) and the Lookup button on the tool bar. In
this case, the user should be able to select a new master record and
press the OK button to exit the list form and change the original card
form to the selected master record.

• The user must be able to open a new card from the list form (by
pressing SHIFT+F5 or clicking the Card menu item on the menu button
that has the same name as the table) that displays the master record
selected on the list form.

Master Statistics Forms

As mentioned above, most master tables will have a card and a list form.
Many master tables also have a statistics form. The user should be able to
get to this form from either the card or the list forms in exactly the same
way.

The standard way of getting to the statistics form is with the shortcut key F9
or the Statistics menu item (on the menu button that has the same name as
the table).
Basic Forms 3-57

Master and Ledger Forms

Every master table has at least (usually only) one ledger table. From the
master forms (card, list and statistics), the user must be able to get to the
ledger form. The user can get there in the three different ways – as a result
of a drilldown button on a FlowField, using CTRL+F5, or the Ledger Entries
menu item (on the menu button that has the same name as the table).

If a drilldown button was pushed, only the records used to create the
calculated value are displayed (this is a function of the built in drilldown
functionality). If the shortcut key or the menu item is used, all ledger
records for this particular master are shown. This requires a RunFormLink
on the menu item that links the two tables. You will also want to keep the
two forms synchronized whenever the master form is updated. For this, you
should also change the RunFormLinkType property to OnUpdate.

Note

For performance reasons, you should always set the RunFormView


property if the RunFormLink property is also set. In fact, the sort chosen in
the RunFormView property must contain the fields listed in the
RunFormLink property or performance will be decreased.

Journal Forms

Every journal form has similar buttons at the bottom of the form. These
buttons allow the user to either navigate to another form or perform a task.

The normal buttons that will be on a journal form are:

• A menu button named after the master table for the functional area.
This menu button must contain menu item s that lets the user go
directly to the card form for the master table or go directly to the ledger
form for the ledger entries. In both cases, the form brought up should
be linked to the master table record that the journal line is associated
with.

• A menu button named “Posting”. This menu button should contain the
following menu items related to posting the journal lines – Post, Post
and Print, Test Report.
3-58 Navision Attain Objects

3.9 ANSWERS TO THE QUESTIONS

3.2.1 Creating a Blank Form

No questions here.

3.2.2 Attaching a Source Table

What is the value in the title bar of the form (this is usually the blue area at
the top of a form that has the Min, Max, and Close buttons on it)?

10000 The Cannon Group PLC – Blank Form

What happens when you click the Next button on the toolbar?

It changes the title bar of the form to the next customer in the customer
table.

Is the form reading information from the source table?

Yes. At least enough to change the title bar.

3.2.3 Adding Simples Controls

You now have a Text Box on your form. What information will it display?

None.

Try running the form by clicking File, Run. What happens?

An error occurs: Data controls must have an expression.

Binding the Text Box

Run the form and test your new Text Box by moving to the next, previous,
first or last record.

The text box should display the No. field from the customer table.

Adding a Label

Run the form and test your new Text Box by moving to the next, previous,
first or last record. The label let’s you know what field you are looking at.

The text box should display the No. field from the customer table.
Basic Forms 3-59

Adding a CheckBox

Run the form and test your new Checkbox by moving to the next, previous,
first or last record. You will also want to check and uncheck the box.

No items are blocked currently.

You should be able to change the Blocked checkbox.

3.2.4 Using Add Label and Lock

What else was put on the form?

A label attached to the Textbox.

What happens when you move the Text Box?

The label moves with it.

What happens when you move the Label?

Only the label moves.

How can you move just the Text Box (hint: look for the hand cursor)?

Select the Textbox and move the mouse over the edge of the selection until
the hand cursor appears. With the hand cursor showing, you can click and
drag just the Textbox.

What happens if you click on the Checkbox button and then click on the
form?

A Checkbox is added to the form along with a label.

Using Lock

How many Text Box controls did you add?

Four Text Boxes.

Can you move any of the controls with the Lock button selected?

No. It will simply create a new Text box control.


3-60 Navision Attain Objects

3.3.1 Adding Container Controls

Using a Tab Control

What happened to the Tab control?

Three new tabs were added Test, Frame and Table Box.

Adding Controls to a Tab

What happens if you click on the General tab and back to the Test tab?

The control disappears when the General tab is selected and reappears
when the Test tab is selected.

Edit the PageNames property of the Tab control so that it looks like
General,Frame,Table Box. Where is the label control now?

On the Frame tab (the second tab in the Tab control).

Move the label control to the bottom of the form (off of the Tab control).
What happens when you change to the General tab and back now?

The label is always visible.

Click on the General tab and move the label from the bottom of the form to
the middle of the General Tab. What happens when you change to the
Frame tab and back?

The control disappears when the Frame tab is selected and reappears
when the General tab is selected. It is again on a page in the tab control.

Adding a Frame Control

What happens if you move the frame?

All of the controls in the frame move with it.

What happens if you delete the frame?

All of the controls in the frame are also deleted.

Adding a TableBox Control

Run the form. What is displayed in the TableBox?


Basic Forms 3-61

Several rows of records from the item table. There is a triangle in the gray
box next to the current row.

What happens to the title bar of the form if you click on another row in the
TableBox?

It changes to the row selected in the table box.

What happens if you maximize the form or simply make it bigger?

The controls all stay the same size and in the same location.

Autosizing Controls

Run the form. What happens now when you resize the form by making it
bigger?

The tab control and the table box grow with the form.

3.3.2 Displaying Options

Using a Text Box

What type of button is in the Text Box?

A DropDown button.

What happens when you click the button?

A short list of choices is presented below the text box.

Using Option Buttons

How many of the Option buttons are selected?

One.

What happens if you try to select another one?

The first option button is unselected.

What happens if you change the Text Box that is bound to the Costing
Method field to Specific?

The third button labeled Specific is selected.


3-62 Navision Attain Objects

What happens if you change the Text Box that is bound to the Costing
Method field to Average?

None of the buttons are selected because there is no button for Average.

3.3.3 Displaying Progress Indicators

Use the next button to look at many different records. What range of values
did you notice?

Everything from 15% to 70%.

What happens if you change the MaxValue property to 1000 and run the
form again?

The values in the indicator are almost invisible. The percentage changes to
less than 1.

3.3.4 Displaying BLOB Fields (Pictures)

Use the next button to look at many different records. List some of the
items that have pictures?

70102 – Paint, blue

1896-S – Athens desk

1906-S – Athens Mobile pedestal

3.4.1 Card Forms

Starting the Wizard

No questions here.

The Card-Type Wizard

No questions here.

3.4.2 Tabular Forms

The Tabular-Type Wizard

What happens?
Basic Forms 3-63

The Find window appears and begins searching for what I type.

Why is this desirable to a user?

The user does not have to remember how to open the Find window. They
can simply click on a column and begin typing. It is faster.

3.4.3 Using the Field Menu

Adding Fields to a Card Form

Does the field work properly?

Yes.

What else got placed on the form with the Text Box?

A label that is attached to the text box.

Adding Fields to a Tabular Form

Does the field work properly?

Yes.

What was the column heading?

Balance. The field name.

Do you think that most users will need to see the Balance field on this
form?

No. Only certain users will use this field on this form.

3.4.4 Making Columns Invisible on a Tabular Form

Can you see the column?

No.

Click View, Show Column. Is the Balance field listed? Is the Net Change
field listed?

Yes. The Balance field is listed.

No. The Net Change field is not listed.


3-64 Navision Attain Objects

Why is the Balance field listed and the Net Change field not?

The Net Change field has not been added to the form. Only fields that have
been added to actual form appear here.

Check the box next to the Balance field and Click OK. Is the Balance field
shown now?

Yes.

What happens if you close the form and run it again?

The Balance field is still on the form so the user can see it.

3.5.1 Creating Command Buttons

What caption does the button have?

OK.

What happens when you click the button?

The form closes.

Run the form again. Resize the form slowly. What happens to your new
button?

It stays where it is and does not stay next to the Help button.

What happened to the Help button?

It moves. It stays in the bottom right corner of the form.

What caused them to act differently?

The glue properties.

Test the form again by resizing it. What happens to your new button?

It stays beside the Help button in the bottom right corner of the form.

3.5.2 The RunObject PushAction

Where is the button? Where are the OK and Cancel buttons?

It is exactly where is was put, but the OK and Cancel buttons are gone.
Basic Forms 3-65

They are not visible.

What happens when you click the button?

Nothing.

What did you forget to set?

The PushAction property.

Run the form again. What happens this time when you click the Card
button?

The card form that I created is opened.

Close the card form. Select customer 50000 on the list form. Click the Card
button. Which customer is displayed on the card form?

The first customer 10000.

3.5.3 Linking Forms

What happens when you click the Card button with customer 50000
selected?

It displays customer 50000 on the card form.

What happens if you close the card form, select another customer and click
the Card button, again?

It displays that customer (the one selected on the list form).

Notice that while the card form is open, you can click back on the list form
and choose another record. What happens to the card form when you
change the list form in this way?

Nothing. It still displays the record of the other customer.

Design the form and change the RunFormLinkType property of the Card
button to OnUpdate. Save your changes and run the form. Now, what
happens when you change the list form while the card form is still open?

It changes to the new customer as well. It stays linked every time the list
form is updated.
3-66 Navision Attain Objects

3.5.4 Creating Menu Buttons

What happens when you click the new menu button?

Nothing.

3.5.5 Creating Menu Items

What happens when you click the menu button now?

A menu of the menu items that I added shows up below the menu button.

What happens when you click the Card menu item?

The card form is displayed for the record that is selected.

What happens when you press SHIFT+F5?

The card form opens with the record selected. Same as clicking the menu
item.

3.5.6 The LookupTable PushAction

What form comes up when you press the F5 function key?

Form 22, the normal Customer List.

Why does that form come up and not your customer list form?

The default lookup form for the customer table is the Customer List form.
My Customer List is not setup as the default lookup form. It is the
LookupformID property of the customer table that tells the system which
form to bring up.

Design table 18 and change the LookupFormID property of the table to


91301. Run your card form again. Now, what form comes up when you
press the F5 function key?

Form 91301, My Customer List.

3.6.1 Creating the Main Form

Open the properties window for the Subform control and write down the
Height and Width properties.

Height 5500
Basic Forms 3-67

Width 9350

What appears where the subform control is?

Nothing.

3.6.2 Creating the Subform

What property of the form could you use to automatically fill in the Line No.
field for you?

AutoSplitKey

What purpose does the Table Name field serve?

This table can hold comments from many master tables. The Table Name
changes the table relation of the No. field to the appropriate master table.

3.6.3 Adding the Subform onto the Main Form

Now, what appears in the spot where the subform control is?

Form 91501

Does the Customer Comment Subform fit into the subform control perfectly
(is it lined up with the tab control)?

It is not perfect. The width is not correct. The scroll bars on the right and
bottom do not appear in the normal place.

Why is there a box around the subform?

It is the border of the subform control.

What happens when you resize the form by making it wider?

The subform control does not expand.

What happens when you resize the form by making it taller?

The Tab control expands and goes under the subform control. The subform
control still does not expand.

What records show up in the subform when you change to a new customer
on the main form?
3-68 Navision Attain Objects

All of the records for every customer.

Are there any other problems with your forms?

No.

Can you insert a new customer?

Yes.

Can you add comments to that new customer?

Yes.

What happens when you change to another customer?

The subform changes so that I only see the comments for the new
customer.
Basic Forms 3-69

3.10 CHAPTER REVIEW

In this section, you will be asked questions about the material covered in
this chapter. Answers to the questions can be found in the subsection
Answers.

Questions

True or False. All forms are bound.

True or False. The form wizard is not useful.

Which property must you set on Command button for the RunObject
property to work?

Which control allows a form to display more than one record at a time?

Which control allows a form to display another form?

Which property of a Text box binds it to a field in a table?

What form property binds a form to a table?

How do you turn a menu item into a submenu on a menu button?

How do you attach a label to another control so that the label follows the
other control if you move it?
3-70 Navision Attain Objects

What are the steps to create a List form for a table?


Basic Forms 3-71

Answers

All forms are bound.

False. Some forms are not related to any table (unbound). For example the
Main Menu form.

The form wizard is not useful.

False. Most forms can be created with the wizard. The only additional items
that must be added are usually buttons.

Which property must you set on Command button for the RunObject
property to work?

You must set PushAction to RunObject.

Which control allows a form to display more than one record at a time?

Tablebox

Which control allows a form to display another form?

Subform

Which property of a Text box binds it to a field in a table?

SourceExpr

What form property binds a form to a table?

SourceTable

How do you turn a menu item into a submenu on a menu button?

Indent other menu items under it using the Right button on the Menu
Designer window.

How do you attach a label to another control so that the label follows the
other control, if you move it?

Click the Add Label button on the Toolbox window before you add the other
control.

What are the steps to create a List form for a table?

Create a tabular form for the table using the wizard.


3-72 Navision Attain Objects

Change the Editable property of the form to False.

Add appropriate buttons to go to the Card, Ledger Entries, and Statistics


Chapter 4.

Basic Reports

Reports are used to print information from a


database. A report can be used to structure and
summarize information, and reports can be used
to print documents such as invoices. Reports can
also be used to process data without printing
anything.

This chapter introduces the fundamental


concepts and basic tasks involved in designing
reports.

This chapter contains the following sections:

Reports

The Report Designers

How Sections Work

Some Useful Properties

Grouping Within a Report

Totaling in a Report

Adding Some Advanced Features

Types of Reports

Creating a Basic Report

Answers to the Questions

Chapter Review
4-2 Navision Attain Objects

4.1 REPORTS

Reports in C/SIDE have several purposes:

• Reports are used to print information from a database in a structured


way. For example, in a sales order application, you can create a report
that contains a list of all customers and for each customer, lists all
orders placed by that customer.

• All documents pertaining to an application must be created as reports.


For example, in order to print an invoice, you will create a report that is
automatically filled out with the relevant information.

• Reports can be non-printing. While this may sound like a contradiction


in terms, it is not. A report can be used to automate many recurring
tasks such as updating all prices in an item list. This could be
performed entirely from C/AL code in a codeunit, but using a report
makes it a lot easier because you can use the powerful data modeling
available for report design.

The following diagram shows the components of a report and their


relationship.

Report Description
Properties
Triggers
Data Items
Properties
Triggers
Sections
Properties
Triggers
Controls
Properties
Request Form
Properties
Triggers
Controls
Properties
Triggers
Basic Reports 4-3

The Report Components

The diagram above outlines how a report is composed from a number of


different components. Below you will find a short description of each
component.

Report Description

This is the total description of the report – how data is collected and how
data is presented on paper when the report is run. The report description is
stored in the database.

Data Item

A data item corresponds to a table. In order to retrieve information from the


tables in the database, you define data items. When a report uses more
than one table, you set relations between the data items in order to retrieve
and organize data in the way that you want.

Section

In a printing report, each data item could have one or more sections. A
section can be thought of as a block of information to print on the paper.
The complete report consists of a number of sections; some that are
printed only once like a grand total, some that are printed once per page,
for example a header, and some that are printed for each record that is
retrieved from the database.

Control

The information that is printed in the sections is composed of controls. The


available controls are text boxes, for printing the result of the evaluation of
any valid C/AL expression such as the contents of a table field (but also
complex calculations), labels for printing static text such as a caption for a
column of data, and shapes, images and picture boxes, for printing graphical
elements (lines, circles) and bitmap pictures in a report.

Request Form

A request form is a form that is run before the actual report begins
execution. It is used to gather requests and options from the user of the
report–for example, sort order or level of detail.
4-4 Navision Attain Objects

Property

A property is an attribute of an object–report, data item, section and so


forth–that characterizes the object in some way – color, size, whether it is
displayed, and much else. Properties are set on the Property Sheet of an
object.

Trigger

Certain predefined events that happen to a report cause the system to


execute a user-definable C/AL function–the event triggers the function. As
you can see in the diagram, the report itself, the data items, the sections,
the request form and the controls on the request form all have triggers.
Triggers are edited in the C/AL editor.

Logical and Visual Design

There are two sides to designing a report: defining the logical structure, the
data model and designing the visual layout.

Defining the data model means defining how the data for the report is
collected. This includes:

• Defining the tables the report will use by creating data items.

• Defining relationships between data items if the report uses more than
one table.

• Defining the key, sort order and filters to use with the involved data
items.

• Defining which elements the user will be able to change at run time.

• Defining how data is to be grouped.

• Defining how subtotals and totals are to be calculated.

• Possibly writing C/AL code in data item triggers to obtain advanced


functionality.

Data Items

The data model of a report is built from data items. A data item
corresponds to a table. When the report is run (see the diagram on page
214), each data item is iterated for all records in the underlying table. When
Basic Reports 4-5

a report is based on more than one table, you establish a hierarchy of data
items to control how the information is gathered by indenting data items.

Example

In order to make a report that prints out a list of customers and for each
customer lists sales orders placed by that customer, you will define two
data items – one that corresponds to the Customer table and one that
corresponds to the Sales Order table. The second data item is indented –
as the report works its way through the records in the Customer table, for
each customer all sales orders that are related to this customer must be
found by going through the records in the Sales Order table.

Sections

The visual layout of a report includes the sections. In a printing report


(remember that reports do not have to print anything), one or more sections
can be attached to each data item. There are several types of sections,
each having a specific function. Normally, the bulk of the data is printed out
in the body section of a data item, while the header section of the data item
is used to print information before any record of the data item is printed (for
example, column captions), but there are reports–like some of the
examples in the lab manual–where the body section is not used at all, and
all information is printed in other sections.

The following picture shows a finished report.

Sales Statistics
Header CRONUS International Inc.
Customer: No.: 10000..30000
Sections

09/28/95 10/28/95 11/28/95


No. Name ...before 10/27/95 11/27/95 12/27/95 after...

10000 Kontorforsyningen A/S

Body Sales (LCY) 57,509.00 0.00 0.00 0.00 0.00


Profit (LCY) 12,655.00 0.00 0.00 0.00 0.00
Sections Profit % 22.0 0.0 0.0 0.0 0.0
Inv. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00
Pmt. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00

20000 Ravel Møbler


Sales (LCY) 1,525.00 0.00 0.00 0.00 0.00
Profit (LCY) 335.00 0.00 0.00 0.00 0.00
4-6 Navision Attain Objects

Profit % 17.9 0.0 0.0 0.0 0.0


Inv. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00
Pmt. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00

30000 Lauritzen
Kontormøbler A/S
Sales (LCY) 13,676.20 0.00 0.00 0.00 0.00
Profit (LCY) 2,444.20 0.00 0.00 0.00 0.00
Profit % 17.9 0.0 0.0 0.0 0.0
Inv. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00
Pmt. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00

Total
Sales (LCY) 72,710.20 0.00 0.00 0.00 0.00
Footer Profit (LCY) 15,434.20 0.00 0.00 0.00 0.00
Profit % 21.2 0.0 0.0 0.0 0.0
Sections
Inv. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00
Pmt. Discounts (LCY) 0.00 0.00 0.00 0.00 0.00

This report prints sales statistics information and retrieves all its data from
one table. It demonstrates a range of the features that are available for
designing reports.

• Before any record from the table is printed, there is a header–


containing a title and information about the filter that was used on the
customer numbers.

• Each body section prints information about a customer on several


lines. The "Profit %" lines are calculated as the report is run.

• After all records (all records that were selected by the filter that is) have
been printed, a footer section is printed that contains totals for the
selected customers.

• In the body section and in the footer section, a filter has been applied
to create columns where data are collected and totaled for different
periods.
Basic Reports 4-7

4.2 THE REPORT DESIGNERS

The Report Designer contains two additional designers – the Section


Designer, used for designing the layout of reports, and the Request
Options Form Designer, used for designing request options forms.

The Report Designer

When you select a report in the Object Designer and press the Design
button, you are taken into the Report Designer.

In the Report Designer window, you define the Data Model by adding Data
items.

In the Report Designer window, you can specify the tables that the report
will read. It is important to note that any table mentioned here will be read
in its entirety during the report. In order to limit the number of records read,
you should link and filter Data items. You could actually read the same
table more than once in the same report by listing it more than once in the
Report Designer. For example, you may want to read customers that are
not blocked first and then customers that are blocked.

The tables that you list become Data items in the report. Data items are
record variables (just like you would use in code) that allow the report to
access the data of a table.

The right column in the Report Designer is the Name that the Data item will
go by throughout the report. Like all variable names, these names should
be unique within the report.

You can use the Report Designer to specify how the report engine should
read the underlying tables:

Ordering the Data items

The order in which the Data items are listed, is the order that the report will
read the data from the tables. At the bottom of the Report Designer
window there are four arrow buttons. You can use the up and down arrow
buttons to reorder the Data items.

Indenting a Data item

You can use the right and left buttons to indent or unindent a Data item.
Indenting a Data item under another Data item affects the report in this
way:
4-8 Navision Attain Objects

• For every record read from the top Data item, all the records will be
read from the indented Data item (this takes into account any filters or
links). (This is similar to a nested FOR loop.)

Linking a Data item

Each Data item has a property called DataItemLinkReference and a


property called DataItemLink. Usually, these are used to define a
Master/Detail relationship between the two tables. In the LinkReference
property, you can choose which other Data item you would like to link with
(this must be a Data item that this Data item is indented under). In the
DataItemLink property, you can specify a filter for this Data item by
matching fields in this Data item with fields from the LinkReference Data
item.

Note

A proper key should be selected for the indented data item. It should
contain the fields that are being used to link the data item.

Exercise 4.2.1 Creating a Data Model

This exercise will help you understand some of the basic design principles
of creating a Navision Report. In this half of the exercise, you will create the
data model in the Report Designer.

1 Open the Object Designer and Click Report.

2 Click New. The New Report window appears. You will not be using
the Report Wizard because it limits you to one table.
Basic Reports 4-9

3 Click OK. The Report Designer appears.

4 Select the first empty line in the Report Designer and enter the
number or name of the Salesperson/Purchaser table (13).

5 Select the next empty line in the Report Designer and enter the
number or name of the Customer table (18).

Because you want the report to look at customers by salesperson, you


must set it up so that it reads the Salesperson/Purchaser table first. Then,
for each salesperson record, it will read all the customers for that
salesperson. This is done by indenting the customer data item under the
salesperson data item and linking the two. See the following steps for
detailed instructions.

1 Indent the Customer data item by clicking the right arrow button at the
bottom of the form.

With the customer data item still selected, bring up the properties for that
data item.

2 Click on the DataItemLinkReference property. Verify that it is set to


Salesperson/Purchaser.
4-10 Navision Attain Objects

3 Click on the DataItemLink property. You need to match the fields that
link the two tables.

4 Click the assist-edit button.

5 In the Field column, select the Salesperson Code field from the
Customer table.

6 In the Reference column, select the Code field from the


Salesperson/Purchaser table.

7 Click OK to save the link.

Whenever you link two data items, you should always sort the indented
data item accordingly. In this case, you should change the
DataItemTableView property of the Customer data item to
SORTING(Salesperson Code).

Close, save and compile the report with the ID 91200 and the name
Customers by Salesperson 1.

The data model is now complete. The next step is to design the page.
Before you do that, you need to know about the Section Designer.

The Section Designer

As you recall, each data item can have one or more sections defined in the
report. The Section Designer lets you design the visual layout of the report
section by section. While you are in the Report Designer, select the View
menu and then Sections.
Basic Reports 4-11

Note

If the report has its Processing Only property set to Yes you cannot create
any sections. This property is discussed later with the other properties.

Each data item can have any number of sections (remember that every
section is a subobject of one of the Data items). Therefore, when you
create a section (F3), you must select the Data item that the section is
associated with and specify the type of section that you need. You can
delete a section by clicking on the gray bar and then pressing F4.

The following table provides a brief description of the types of sections in a


report:

Section Description

Body This section is printed once for every record that is


processed by the Data item. If a record is skipped or
is filtered out, this section is not printed for that
record.

Footer This section is printed last for a Data item. By default


it is only printed once each time the Data item is
processed, but you can choose to print it on every
page. You can also specify this section is printed at
the bottom of the page, which ensures that the
section will be placed on the page as close to the
bottom as possible.

GroupFooter This section is printed right after the last record in a


group that is processed. This section will ONLY print
if the GroupTotalFields property for the Data item is
set and the Data item is appropriately sorted.

GroupHeader This section is printed right before the first record in a


group that is processed. This section will ONLY print
if the GroupTotalFields property for the Data item is
set and the Data item is appropriately sorted.

Header This section is printed first for a Data item. By default


it is only printed once each time that the Data item is
processed, but you can select to print it on every
page.
4-12 Navision Attain Objects

Section Description

TransFooter This section is printed at the bottom of a page for a


data item that will be continued on the next page.

TransHeader This section is printed at the top of a page for a data


item that continues from the previous page.

Each section works like a small form with the SourceTable property set to
the data item’s table. Controls on sections do not have any triggers but do
have the same properties as on a form.

Note

While you can see colors that you set for controls in the design of a section,
these colors will NOT be printed when you actually run the report. The only
way to print colors is to use Image or PictureBox controls.

Exercise 4.2.2 Designing the Page Layout

In this exercise, you will define the sections and finish the report that you
started earlier.

1 Open report 91200 in the Report Designer.

2 On the main menu, click View, Sections. You should see two sections
that have already been created for you by the report:

• Salesperson/Purchaser body(1)

• Customer body(1).
Basic Reports 4-13

3 Click F3 to insert another section. The Insert Section window


appears.

4 Select the Salesperson/Purchaser data item and a section type of


Header. This will insert a Salesperson Header into the sections (the
header section for a data item will always come before the body
section).

5 Click OK to insert the desired section.

Notice that a new gray bar appears with the name


4-14 Navision Attain Objects

Salesperson/Purchaser Header(1).

6 Repeat steps 4 and 5 to insert a Customer header section.

You should now have four sections in your report. But they do not
have any controls on them. If you were to run the report, nothing
would be printed on the pages.

7 Click the Salesperson/Purchaser body section.

8 Click View, Field Menu. The Field Menu window appears.

9 Hold down the CTRL key and select the Code and Name fields.

10 Move your mouse over the Salesperson/Purchaser body section.

11 Click once to activate the Sections Designer.

12 Click again to create the fields on the section.

Notice that the labels and text boxes are created differently on a report
section than on a form. The labels are placed above the text boxes in
columns. Your labels are probably on top of the text boxes because
the section was too small to put them above the text boxes. You can
move the controls around just like you did with forms.

13 Drag the labels one at a time from the body section to the header
section and line them up with the corresponding text boxes.

14 Repeat steps 7-13 for the Customer body section. Add the No.,
Name, City, and Phone No. fields from the Customer table. Don’t
forget to move the labels to the header section.
Basic Reports 4-15

15 Close, save and compile the report. You do not have to save a report
before you run it, but it is a very good idea. You never know when
your computer might crash. Save regularly when designing reports!

16 Run the report. The request form appears. This form allows the user
to enter filters for the data items or change the sort of the data items.
They can also choose to Print the report or Preview the report.

17 Click Preview.

Note

If you do not have a printer driver loaded for Windows you will not be able
to print or preview any reports.

Does the report look the way you expected it to? Where do the header
sections print for each data item?

Did the header sections ever repeat?


4-16 Navision Attain Objects

The Request Options Form Designer

While you are in the Report Designer, you can select the View menu and
then Request Form.

Use the Request Options Form Designer to design the Options tab of the
Request Form. The request form is the form that is displayed to the user
when they run the report.

You cannot design the data item tabs or the buttons at the bottom of the
Request Form from here. This is just like any other form you create.
Remember that the Options tab will be the last tab on the Request Form.

When you add controls to this form, the Options tab will be displayed. The
Options tab will not be visible to the user until you add some controls.

You must usually include some triggers before you can utilize the Options
tab of the request form. As this course only deals with basic reports, you
will not be adding controls to the request form.

The other tabs of the request form can be changed via properties, as you
will see in the rest of this chapter.
Basic Reports 4-17

4.3 HOW SECTIONS WORK

In this section, you learn how certain types of sections can be used and
when they are printed.

Exercise 4.3.1 Headers, Bodies, and Footers

In this exercise you experiment with header, body and footer sections.
First, without indentation or linking, then, with indentation and finally with
linking.

No Indentation or Linking

1 Open the Object Designer and click Report.

2 Click New and the New Report window appears. You will not be using
the Report Wizard, because it limits you to one table.

3 Click OK and the Report Designer appears.

4 Click the first empty line in the Report Designer and enter the number
or name of the Salesperson/Purchaser table (13).

5 Click the next empty line in the Report Designer and enter the number
or name of the Customer table (18). Do not indent or link the two data
items.

6 Click on the Customer data item

7 Open the Properties window.

8 Change the MaxIteration property to 5.

9 Click View, Sections.

10 Insert a header for each data item. You should now have four
sections. Insert a footer for each data item as well.

11 On the Salesperson Body, place the Code and Name fields and drag
the labels to the header.

12 On the Customer Body place the No., Name, and Phone No. fields
and move the labels to the header.
4-18 Navision Attain Objects

13 On the Footer for each data item, place a label from the toolbox and
change the caption to SP-footer and Cust-Footer respectively.

14 Close, save and compile the report with the ID 91300 and the name
Basic Sections Test.

15 Run the report.

How did the report loop through the tables?

Where does each data item’s Header section print?

Where does each data item’s Footer section print?

With Indentation

1 Open the report in the Report Designer.

2 Indent the Customer data item (do not link it yet).

3 Close, save, and compile the report.

4 Run the report.

How did the report loop through the tables?

Where does each data item’s Header section print?


Basic Reports 4-19

Where does each data item’s Footer section print?

With Linking

1 Open the report in the Report Designer.

2 Select the Customer data item.

3 Change the DataItemLink property to Salesperson


Code=FIELD(Code).

4 Remember that you also need to set the sorting for the report. Add the
SalesPerson Code Key to the Customer table. Change the
DataItemTableView property to SORTING(Salesperson Code).

5 Close, save and compile the report.

6 Run the report.

How did the report loop through the tables?

Where does each data item’s Header section print?

Where does each data item’s Footer section print?

Exercise 4.3.2 TransHeaders and TransFooters

In this exercise, you will add a TransHeader and a TransFooter to the


previous report.

1 Open report 91300 in the Report Designer.

2 Select the Customer data item.

3 Open the Properties window.

4 Delete the value in the MaxIteration property.

5 Close, save and compile the report.


4-20 Navision Attain Objects

6 Run the report.

Notice that the Customers for some of the salespeople extend to more than
one page. However, on the second page, the report does not print any
headings, that tell us, what salesperson we are looking at. It would be nice
if we could get our headings printed on every page.

1 Open report 91300 in the Report Designer.

2 Click View, Sections.

3 Select each of the Header sections on the report and change the
PrintOnEveryPage property to Yes.

4 Close, save and compile the report.

5 Run the report.

Now, the Salesperson header and the Customer header appear at the top
of every page. This still doesn’t tell us which salesperson those customers
go with. What we need here is a section that will print at the top of just
those pages that are continuations of the previous page and show the
salesperson that we are currently on.

This is what a TransHeader does. First, you need to determine what data
item the TransHeader section goes with. You should ask yourself “which
data item is the report in the middle of printing when it goes to the next
page (where I want the TransHeader)?” The answer in your case is the
customer data item.

1 Click on the Customer body section.

2 Insert a TransHeader section for the customer data item. Note that it
comes between the header and the body sections. In the Customer
TransHeader section, you need to display the current salesperson.

3 Click on the Salesperson Body section and select both the Code and
Name fields.

4 Click Edit, Copy to copy these controls to the clipboard.

5 Select the new TransHeader section.

6 Click Edit, Paste to copy the two controls to this section. Line them up
with the ones that you copied. This will almost work. Because we are
Basic Reports 4-21

in a section of the customer data item now, we can not display fields
from another data item without specifying the data item first.

7 Select the Code text box control and open the Properties window.

8 Change the SourceExpr property to Salesperson/Purchaser.Code.


You have now specified the other data item that Code is actually a
part of.

9 Repeat this process for the Name text box. The value for the
SourceExpr property should be “Salesperson/Purchaser”.Name. You
will also want to add a label to this section that has the word
Continued in the caption.

10 Close, save and compile the report.

11 Run the report.

Where did the TransHeader print (it will not be on every page)?

Transfooter

A TransFooter works basically the same as the TransHeader but it prints at


the bottom of the page that had to be continued.

1 Open report 91300 in the Report Designer.

2 Click View, Sections.

3 Select the Customer Body section.


4-22 Navision Attain Objects

4 Insert a TransFooter section for the Customer data item.

5 Add the label Continued on Next Page… in the Caption property.

6 Close, save, and compile the report.

7 Run the report.

Where did the TransFooter print (it will not be on every page)?
Basic Reports 4-23

4.4 SOME USEFUL PROPERTIES

In this section, the exercises will help you understand some useful
properties. You will be slowly improving the report that you created in the
previous exercises.

Exercise 4.4.1 NewPagePerRecord Property

Your user would like the Customer by Salesperson report to start a new
page every time it finds a new salesperson. There is a property designed
just for this - NewPagePerRecord.

1 Open report 91300 in the Report Designer.

2 Select the Salesperson/Purchaser data item.

3 Change the NewPagePerRecord property to Yes.

4 Close, save and compile the report.

5 Run the report.

When does a new page get created now (there are two times)?

Exercise 4.4.2 PrintOnlyIfDetail Property

You may now notice that the report does not contain any customers for
salesperson Alice Hart. She is not really a Salesperson. She is a
Purchaser. We need to change the report to only include those
Salespeople that actually have Customers. Remember that in this report
customer is the detail data item.

1 Open report 91300 in the Report Designer.

2 Select the Salesperson/Purchaser data item. This is the master data


item. The customer data item is the detail data item. The report should
only print master records that have details.

3 Change the PrintOnlyIfDetail property to Yes.

4 Close, save and compile the report.

5 Run the report.

Which salespeople are printed on the report?


4-24 Navision Attain Objects

Exercise 4.4.3 ReqFilterFields and ReqFilterHeading

You user would like the report to allow filtering on the Code and Name
fields of the Salesperson/Purchaser table on the request form. The property
ReqFilterFields allows you to specify which fields the user can see on the
request form.

1 Open report 91300 in the Report Designer.

2 Select the Salesperson/Purchaser data item.

3 Change the ReqFilterFields property to Code,Name.

4 Close, save and compile the report.

5 Run the report.

What fields appeared on the Salesperson/Purchaser tab of the request


form?

Can you filter on any other fields?

What else does the tab allow you to do to the data item?

You may also want to change the name of the tab (or the Heading) from
Salesperson/Purchaser to just Salesperson on the request form. The
property ReqFilterHeading allows you to change the name of the tab on the
request form.

1 Open report 91300 in the Report Designer.

2 Select the Salesperson/Purchaser data item.

3 Change the ReqFilterHeading property to Salesperson.

4 Close, save and compile the report.

5 Run the report.

What name appeared on the tab?


Basic Reports 4-25

Note

Sorting a data item that does not have ReqFilterFields causes its Tab on
the Request Form to disappear.
4-26 Navision Attain Objects

4.5 GROUPING WITHIN A REPORT

In this section, you will learn how to group data within a report.

What is Grouping?

In a report you will generally need to print subtotals or to separate groups


of records based on fields within the records themselves. In Navision, you
must tell the report which fields you would like to monitor for these events.
The report monitors the fields and when they change to a new value, it
triggers special sections to print on the report. These special sections do
not print unless the report is grouping on fields.

Keep in mind that Grouping is not a necessity if you can use indentation to
link and filter your data items the way that you want. Grouping must be
used in cases where the field that you want to group on is not related to
another table.

The most common use for grouping is to subtotal a report by Date. Date
fields are not related to a table but do signify important groups within the
table. For example, you may want to look at Customer Ledger Entries by
Customer and for each Customer by date. You only need to Group on one
field – Date. You can “Group” (this is in quotations because while the term
is correct, here we are not actually talking about Grouping the report) the
entries by Customer using indentation.

Note

In most cases, it is easier to use indentation rather than grouping. Grouping


on more than one field is somewhat tricky and requires you to write some
code. Indentation is a more natural way to use the Report Designer (if you
can).

The GroupTotalFields Property

This property is the key to printing the special sections. You must specify
the fields that you want the report to monitor (or break on) in this property
to group the report. This property has nothing to do with Totals or with
indentation. The name of the property is somewhat misleading.

To properly use this field, you must do two things.

• First, the fields you specify in this property (and there can be more than
one) must also be in the key that you specify in the DataItemTableView
Basic Reports 4-27

property. If you do not choose an appropriate key, the


GroupTotalFields that you specify will be ignored by the report.

• Second, you must create these special sections. The only thing that
Grouping does is print these sections at the correct time.

The GroupHeader and GroupFooter Sections

Grouping a report allows you to print GroupHeader and GroupFooter


sections. As their names imply, they are printed before a group starts and
after a group has finished. The GroupHeader section prints after any
Header sections and before any body sections for this group (or right after
the previous group’s GroupFooter). The GroupFooter section prints after
the last body section for this group and before the GroupHeader of the next
group (or before the footer section).

Exercise 4.5.1 How Grouping Works

In this exercise, you will create a report with one data item and use
grouping to form breaks in the report.

1 Open the Object Designer.

2 Click Report.

3 Click New and the New Report window appears. You will not be using
the Report Wizard, although it could be used to create this report.

4 Click OK and the Report Designer appears.

5 Select the first empty line in the Report Designer and enter the
number or name of the Cust. Ledger Entry table (21).

6 Change the GroupTotalFields property to Posting Date.

7 Click View, Sections.

8 Insert a Header section.

9 Insert a Group Header section.

10 In the body section, add the Posting Date, Customer No.,


Document Type, Document No., Description and Amount fields.

11 Move the labels up to the Header section.


4-28 Navision Attain Objects

12 Select the Posting Date text box and drag it from the body section to
the Group Header section.

13 Change the FontBold property to Yes.

14 Close, save and compile the report with the ID 91500 and the name
Customer Detail.

15 Run the report.

Where did the Group Header Section print?

Why didn’t it print?

Creating a Needed Key

Remember that you must sort the data item using the field(s) that you want
to group on. Unfortunately, there is no key in the Cust. Ledger Entry table
that starts with the Posting Date field. So, you will create a new key in the
underlying table. You might have to do this in many reports that you create.

1 Open table 21 in the Table Designer.

2 Click View, Keys.

3 Select an empty line at the bottom of the Key Designer window.

4 Enter Posting Date into the Key column.

5 Close the Key Designer window.

6 Close, save and compile the table.


Basic Reports 4-29

Finishing Up

Now, you can finish your report.

1 Open report 91500 in the Report Designer.

2 Select the data item and open the Properties window.

3 Change the DataItemTableView property to SORTING(Posting Date).


You can use the assist-edit button to open the Table View window
and choose the new key you created.

4 Close, save and compile the report.

5 Run the report.

Where did the Group Header Section print?

Exercise 4.5.2 How Grouping and Indentation Can Work Together

In this exercise, you will learn how grouping and indentation can work
together to group data at many different levels.

1 Open report 91500 in the Report Designer.

2 Click File, Save As.

3 Enter the ID 91501 and the name Customer Detail 2.

4 Click OK to save the report with the new ID and name.

You will now change this report so that it groups the Customer Ledger
Entries first by Customer and then by posting date. Instead of trying to
add Customer No. to the GroupTotalFields property, you will use
indentation to group by Customer.

5 Insert (F3) a line above the Cust. Ledger Entry data item.

6 Select the Customer table for this new data item.

7 Indent the Cust. Ledger Entry data item once under the Customer
data item.

8 Change the DataItemLink property for the Cust. Ledger Entry data
item to “Customer No.” = FIELD(“No.”). You can use the assist-edit
button to help you set this property.
4-30 Navision Attain Objects

Remember that you should always use an appropriate key for


indented data items. For this situation, you want the ledger entries to
be sorted by Customer No. and then by Posting Date. There is a key
with those fields first.

9 Change the DataItemTableView property to sort by a key that contains


Customer No. and then Posting Date.

10 Click File, Save to save the report.

11 Click View, Sections.

You must now insert a Header section for the Customer data item.

12 On the Customer body section add the No., Name, City, and Phone
No. fields.

13 Move the labels up to the Header section.

You might want to move the controls on the Cust. Ledger Entry
sections over to the right to show the indentation that we are using.
You may Note the “>” symbol in the gray bar of the Ledger sections.
This signifies that this data item is indented. To do this, simply select
all the controls on a section and move them to the right as you would
on a form.

14 Close, save and compile the report.

15 Run the report and the request form appears.

16 Click Preview.

Where did the Group Header Section print?


Basic Reports 4-31

Where did the Header sections print for each data item?
4-32 Navision Attain Objects

4.6 TOTALING IN A REPORT

In this section, you will learn how to add totals to the footer sections in a
report. This is actually very easy, as you will see in the exercises.

What is Totaling?

Almost always in a financials package, a report is designed to summarize


some information that is in the database. This usually requires summing
one or more fields that are being displayed or read by the report and then
displaying the Sum. We call this process “Totaling” the report.

Navision Attain uses Subtotals and Grandtotals. Subtotals come after some
logical grouping of records and sum the group. Grandtotals come at the
very end of the report and sum the entire report (all subtotals).

The TotalFields Property

Before the report will calculate a total for you, you must tell the report which
fields it should total (sum). The TotalFields property of a data item allows
you to specify the fields that you want to sum. By naming a field in this
property, you are telling the report to keep up with totals for that field
throughout the report. This does not, however, tell the report to display the
totals.

How Do I Display the Totals?

To display the total amounts for the Fields you have specified in the
TotalFields property, you need to do two things:

• First, create a section to display the Totals. The report will only display
total amounts on some type of Footer section (Footer, GroupFooter,
TransFooter or TransHeader).

• Second, bring up the field menu for that section and drop the fields that
you are summing into that section. You may want to delete the labels
and line up the controls with the correct columns. That’s it. Because
you are displaying these fields on a Footer type of section, instead of
showing the current value of the fields, the report shows the total
amounts.

Exercise 4.6.1 Creating Subtotals and Grand Totals

In this exercise, you add subtotals and grand totals to one of the reports
you created in Section 4.5.
Basic Reports 4-33

1 Open report 91500 in the Report Designer.

2 Select the Cust. Ledger Entry data item.

3 Open the Properties window.

4 Change the TotalFields property to Amount. This tells the report to


calculate totals for the Amount field as this data item is processed.

5 Click View, Sections.

6 Insert a GroupFooter section and a Footer section.

7 Open the Field Menu window.

8 Select the Amount field.

9 Add this field to the Group Footer section.

10 Delete the label.

11 Line up the Amount field with the amount column. You may want to
change the font or make it bold as well.

12 Repeat this process for the Footer section.

13 Close, save and compile the report.

14 Run the report. The request form appears.

15 Click Preview.

Do the totals seem correct?


4-34 Navision Attain Objects

How did you tell the system that the Amount field on the Group Footer
section should show the total for just that group?

Exercise 4.6.2 Adding Subtotals and Grand Totals to Indented Data Items

In this exercise you will add subtotals to your report that has indentation
and grouping.

1 Open report 91501 in the Report Designer.

2 Select the Cust. Ledger Entry data item.

3 Open the Properties window.

4 Change the TotalFields property to Amount. This tells the report to


calculate totals for the Amount field as this data item is processed
(the report only calculates totals for one data item at a time).

5 Click View, Sections.

6 Insert a Group Footer and a Footer section for the Cust. Ledger Entry
data item.

7 Open the Field Menu window.

8 Select the Amount field and add this field to the Group Footer section.

9 Delete the label.

10 Line up the Amount field with the amount column. You may want to
change the font or make it bold as well.

11 Repeat this process for the Footer section.


Basic Reports 4-35

12 Close, save and compile the report.

13 Run the report. The request form appears.

14 Click Preview.

Do the totals seem correct?

What total prints on the Group Footer section?

What total prints on the Footer section?

Is it possible to add a Grand Total to this report without writing code?


4-36 Navision Attain Objects

4.7 ADDING SOME ADVANCED FEATURES

In this section, you will discover some of the interesting things that are
possible with reports. Some of these features require a line of code or two,
but you will be instructed exactly where to place the code.

You will learn how to use FlowFilters in reports, modify the request form,
skip sections, and perform grand totals with more than one data item.

Exercise 4.7.1 Using FlowFilters in a Report

In this exercise, you will add the ability to filter the report with the Date
Filter field in the Customer table. This exercise depends on the exercises
in section 4.6. You must complete those exercises before attempting these.

1 Open report 91501 in the Report Designer.

2 Select the Customer data item.

3 Change the ReqFilterFields to include the Date Filter field.

4 Close, save and compile the report.

5 Run the report. The request form appears.

6 In the Filter column for the Date Filter field, enter the range
01/01/01..12/31/01.

7 Click Preview.

Are there any records on the report that are outside of that range?

Why do you think the report did not change?

8 Design report 91501.

9 Select the Cust. Ledger Entry data item.

10 Change the DataItemLink property to Customer


No.=FIELD(No.),Posting Date=FIELD(Date Filter). You may want to
use the assist-edit button to help you change this property.
Basic Reports 4-37

11 Close, save and compile the report.

12 Run the report. The request form appears.

13 In the Filter column for the Date Filter field, enter the range
01/01/01..12/31/01.

14 Click Preview.

Are there any records on the report that are outside of that range?

What happens to the report if you leave the Date Filter empty on the
request form?

Exercise 4.7.2 Adding and Taking Away from the Request Form

In this exercise, you will add a checkbox to the Options tab of the request
form and take away other tabs on the request form.

Appearing and Disappearing Tabs

You may have noticed that not every data item seems to have a tab (on the
request form) on the reports that you’ve created. Actually, every data item
does have a tab but depending on certain properties the tab may or may
not appear on the request form.

1 Run report 91501. The request form appears.

What tabs appear on the request form?

2 Open report 91501 in the Report Designer.

3 Select the Cust. Ledger Entry data item.

4 Erase the DataItemTableView property to set it back to the default


value.

5 Close, save and compile the report.

6 Run the report. The request form appears.

What tabs are on the request form now?


4-38 Navision Attain Objects

What can the user do on each tab (notice the button)?

7 Open report 91501 in the Report Designer.

8 Select the Cust. Ledger Entry data item.

9 Change the DataItemTableView property to SORTING(Customer


No.,Posting Date,Currency Code).

10 Close, save and compile the report.

11 Run the report. The request form appears.

What tabs are on the request form now?

12 Open report 91501 in the Report Designer.

13 Select the Cust. Ledger Entry data item.

14 Change the ReqFilterFields to Posting Date

15 Close, save and compile the report.

16 Run the report. The request form appears.

What tabs are on the request form now?

What can the user do on the Cust. Ledger Entry tab ?

Which two properties determine whether the user sees the tab for a data
item on the request form?

Adding a Checkbox to the Options Tab

To add a data control to the Options tab of the request form, you first need
to create a global variable for the control to be bound to. The user will
change the value of the variable through the control. You will use the value
of the variable in the next exercise.
Basic Reports 4-39

1 Open report 91501 in the Report Designer.

2 Click View, C/AL Globals. The C/AL Globals window appears.

3 Add a variable named ShowDetails and set the data type to Boolean.

4 Close the C/AL Globals window.

5 Click View, Request Form and the Request Form Options Designer
appears.

6 Add a checkbox and label (use the Add Label button) to the form.

7 Change the caption property of the checkbox to Show Details. This


will change the caption of the attached label.

8 Change the SourceExpr property of the checkbox to ShowDetails.

9 Close the Request Form Options Designer.

10 Close, save and compile the report.

11 Run the report. The request form appears.

What tabs are on the request form now?

Can you change the value of the checkbox you added?

What value does the variable have when the box is checked?

What value does the variable have when the box is not checked?

Check the box and preview the report. Close the preview window and rerun
the report. Is the box still checked?

Every time the report is run, the variable is set to its default value of False.
To get the value to be remembered, you must tell the request form to save
4-40 Navision Attain Objects

its variable values in the ZUP file.

12 Open report 91501 in the Report Designer.

13 Click View, Request Form. The Request Form Options Designer


appears.

14 Open the Properties window for the form.

15 Change the SaveValues property to Yes.

16 Close the Request Form Options Designer.

17 Close, save, and compile the report.

18 Run the report. The request form appears.

Check the box and preview the report. Close the preview window and rerun
the report. Is the box still checked?

Exercise 4.7.3 Skipping Sections in a Report

In this exercise, you will use the value of the variable that you added in the
previous exercise to display or not display a section on the printed report.
The section that you will conditionally show is the Cust. Ledger Entry Body
section.

1 Open report 91501 in the Report Designer.

2 Click View, Sections. The Sections Designer appears.

3 Click on the Cust. Ledger Entry Body section’s gray bar. This selects
that section.

4 Click View, C/AL Code (F9). The C/AL Editor appears.

5 In the OnPreSection Trigger enter the following code:

CurrReport.SHOWOUTPUT(ShowDetails);

6 Close the C/AL Editor and the Sections Designer.

7 Close, save, and compile the report.

8 Run the report. The request form appears.


Basic Reports 4-41

9 Make sure that the checkbox is checked on the Options tab.

10 Click Preview.

Does the report look the same as the last time you ran the report?

Close the preview window. Rerun the report and make sure the checkbox
is not checked on the Options tab.

What has changed on the report?

Exercise 4.7.4 Adding a Grand Total with More Than One Data Item

In this exercise, you will add a grand total to the Customer Detail 2 report.
This is not possible without some amount of code. In this case, you will add
just one line of code to the report and, of course, a new section.

1 Open report 91501 in the Report Designer.

2 Select the Customer data item to select it.

3 Click View, C/AL Code (F9). The C/AL Editor appears.

4 In the OnPreDataitem Trigger enter the following code:

CurrReport.CREATETOTALS("Cust. Ledger Entry".Amount);

5 Close the C/AL Editor.

6 Click View, Sections.

7 Insert a Footer section for the Customer data item.

8 On that footer section, manually add a Textbox.

9 Change the SourceExpr property of the Textbox to "Cust. Ledger


Entry".Amount. You may also want to increase the font size or make
the textbox bold.

10 Close the Sections Designer.

11 Close, save and compile the report.

12 Run the report. The request form appears.


4-42 Navision Attain Objects

13 Make sure that the checkbox is checked on the Options tab.

14 Click Preview.

Does the total at the end of the report seem correct?

How else might you have done this?

Exercise 4.7.5 Adding Multilanguage Functionality to Your Report

Every caption on the request form or in the sections must have the
CaptionML and OptionCaptionML property populated. If not, your user will
see some captions in English and others in the language chosen on the
report and request form. Bound controls should already have this property
populated. However, any new fields to hold variables or calculated fields
will also need to have the OptionML populated. See Basic Tables for more
information on how to populate this property.
Basic Reports 4-43

4.8 TYPES OF REPORTS

In this section, you will learn about the types of reports that are found in a
normal functional area. The types of reports are not nearly so formal as the
types of forms or tables. This is just a brief outline that will help you in
further discussions about the system architecture.

List Reports

A List report contains a single DataItem that is the table that is being listed.

The table is either a Master table or a Supplemental table.

Each column contains a field from the table, and the data is printed from
that table, not brought in from other tables or calculated from other tables.

The name is usually the name of the table followed by the word "List", or
sometimes followed by the word "Listing".

Examples

• Customer Listing

• Item List

Test Reports

A Test report is a report printed from a Journal table.

Its purpose is to test each of the Journal Lines according to the same
criteria that will be used for Posting, so that all of the errors can be found
and fixed before posting.

Once an error is found during posting, processing stops and the error must
be fixed before Posting can be attempted again.

Thus, in a journal with multiple errors, a test report is a good way of finding
these errors.

The name is usually the name of the corresponding Journal form followed
by the word "Test".

Examples

• General Journal – Test


4-44 Navision Attain Objects

• Resource Journal – Test

• Payroll Journal Test Report

Posting Reports

A Posting report can be printed as part of the "post and print" option on a
Journal.

It is actually a report that is printed from the Register, and has the same
name as that Register.

It lists all of the transactions (that is, Ledger Entries) that have been posted
into that Register.

Examples

• G/L Register

• Item Register

• Payroll Register

Transaction Reports

A Transaction report has two DataItems.

The first is the Master table, and the second is the corresponding Ledger
table.

Normally, a Transaction Report lists all of the ledger entries for each record
in the Ledger table.

Normally, there is a subtotal for each Master table record, and a grand total
for all tables printed.

This report is used to view all transactions for a particular Master record.

There is no standard name for this kind of report.

Examples

• Trial Balance Detail/Summary


Basic Reports 4-45

• Vendor Account Detail

• Employee Transaction Detail

Other "Normal" Reports

Reports are more loosely defined than other application objects because
they are so often customized for a particular client. However, most reports
do consist of a tabular listing with records listed horizontally and each field
displaying in its own column. Many times, there will be some sort of group
heading or total to split the lines among various categories and subtotal the
lines by the categories.

Examples

• Item Status by Salesperson

• Vendor 1099 Information

• Item Sales by Customer

Document Reports

Document reports are different from most other reports, in that, many of the
fields are not displayed in columns.

An example of this kind of report is an Invoice, where the header


information is printed as though filling out an invoice document, and where
this header information is repeated at the top of each page and where no
page has information from more than one header.

The lines for the invoice, print out more like a normal report in rows and
columns.

The lines correspond to the header on the same page, and lines from other
invoices do not display on the same page.

Examples

• Sales Invoice

• Customer Statement

• Purchase Order
4-46 Navision Attain Objects

4.9 CREATING A BASIC REPORT

In this exercise, you will test your abilities to create a simple report. There
are no step by step instructions in this section. Once you have tried this for
yourself, you may want to look at the step by step instructions in the
Answers to Questions section.

Here are the requirements for your report. Use the ID 91700 and the Name
Vendor Detail for this report.

Create a report that has the following requirements:

• Prints Vendor Ledger Entries by Vendor (two data items, use


indentation).

• Displays No., Name, and Phone No. from the Vendor table.

• Displays Posting Date, Document Type, Document No., Description,


and Amount from the Vendor Ledger Entry table.

• Displays a subtotal on the Amount field for the Vendor.

Change that report to include another subtotal such as a subtotal for each
unique posting date that applies to a certain vendor. This will require
grouping on the Posting Date field. Don’t forget to choose an appropriate
key.

Change the report so that it doesn’t print vendors that do not have any
detail records.

Change the report so that it doesn’t print any Ledger records whose
Document type is Credit Memo. This will require filtering on that data item.
Remember that the word View means Sorting and Filtering.
Basic Reports 4-47

4.10 ANSWERS TO THE QUESTIONS

Exercise 4.2.1 Creating a Data Model

No questions here.

Exercise 4.2.2 Designing the Page Layout

Does the report look like you expected it to? Where do the header sections
print for each data item?

Yes.

The Header section for the Salesperson data item only prints at the top of
the first page.

The Header section for the Customer data item prints after every
Salesperson body section, if that Salesperson has customers. It does not
print for the Salesperson if there are no customers.

Did the header sections ever repeat?

Yes the Header section for the Customer data item repeats for every
Salesperson that has customers.

Exercise 4.3.1 Headers, Bodies, and Footers

How did the report loop through the tables?

It looped through all of the Salespeople first. Then, it looped through all of
the Customers (stopping at the fifth customer record).

Where does each data item’s Header section print?

Right before it begins printing the body sections. They only print once.

Where does each data item’s Footer section print?

Right after all the body sections have been printed. They only print once.

With Indentation

How did the report loop through the tables?


4-48 Navision Attain Objects

It looped through all of the Salespeople first, but for every salesperson
record, it looped through the Customer table (stopping at the fifth customer
record).

Where does each data item’s Header section print?

Right before it begins printing the body sections. The salesperson header
section only prints once at the top of the first page. The customer Header
section prints right after every salesperson body section.

Where does each data item’s Footer section print?

After all the body sections have been printed. The customer footer section
prints several times during the report right before the next salesperson
body (or footer) section prints. The salesperson footer section prints once
at the very end of the report.

With Linking

How did the report loop through the tables?

It looped through all of the Salespeople first, but for every salesperson
record, it looped through the Customers for that salesperson (if there were
any; stopping at the fifth customer record).

Where does each data item’s Header section print?

Right before it begins printing the body sections. The salesperson header
section only prints once at the top of the first page. The customer Header
section prints right after every salesperson body section (if the salesperson
has customers).

Where does each data item’s Footer section print?

After all the body sections have been printed. The customer footer section
prints several times during the report right before the next salesperson
body (or footer) section prints. The salesperson footer section prints once
at the very end of the report.

Exercise 4.3.2 TransHeaders and TransFooters

Where did the TransHeader print (it will not be on every page)?

At the top of the second page after the Salesperson Header and Customer
Header.
Basic Reports 4-49

Transfooter

Where did the TransFooter print (it will not be on every page)?

At the very bottom of the first page.

Exercise 4.4.1 NewPagePerRecord Property

When does a new page get created now (there are two times)?

When the report continues to the next page and when the Salesperson
data item moves to the next record.

Exercise 4.4.2 PrintOnlyIfDetail Property

Which salespeople are printed on the report?

JR and PS

Exercise 4.4.3 ReqFilterFields and ReqFilterHeading

What fields appeared on the Salesperson/Purchaser tab of the request


form?

Code and Name

Can you filter on any other fields?

Yes. I can click on an empty line and add any other field from the table.

What else does the tab allow you to do to the data item?

Sort it. I can click on the sort button and change the key that the report
uses.

What name appeared on the tab?

Salesperson

Exercise 4.5.1 How Grouping WorksWhere did the Group Header Section
print?

It did not print on the report.

Why didn’t it print?


4-50 Navision Attain Objects

I forgot to sort the data item with a key that starts contains Posting Date.

Creating a Needed Key

Finishing Up

Where did the Group Header Section print?

Before the body sections that contained a new date.

Exercise 4.5.2 How Grouping and Indentation Can Work Together

Where did the Group Header Section print?

Before the body sections that contained a new date.

Where did the Header sections print for each data item?

The customer header section printed at the top of the first page. The
customer ledger header section printed right after every customer body
section (for customers that had detail records).

Exercise 4.6.1 Creating Subtotals and Grand Totals

Do the totals seem correct?

Yes. The subtotals are more than the lines and the grand total is more than
any subtotal.

How did you tell the system that the Amount field on the Group Footer
section should show the total for just that group?

Simply by setting the TotalFields property. The report replaces the value for
the amount field with the value from the sum of the amount fields for the
group.

Exercise 4.6.2 Adding Subtotals and Grand Totals to Indented Data Items

Do the totals seem correct?

Yes. The subtotals are more than the lines.

What total prints on the Group Footer section?

Total for that date.


Basic Reports 4-51

What total prints on the Footer section?

Total for that customer.

Is it possible to add a Grand Total to this report without writing code?

No. The report can only total on one data item at a time.

Creating a Basic Report

Here are the step-by-step instructions on how to do this report.

Stage 1

1 Open the Object Designer.

2 Click Report.

3 Click New. The New Report window appears.

4 Click OK. The Report Designer appears.

5 Select the first empty line in the Report Designer and enter the
number or name of the Vendor table (23).

6 Select the next empty line in the Report Designer and enter the
number or name of the Vendor Ledger Entry table (25).

7 Indent the Vendor Ledger Entry data item by clicking the right arrow
button at the bottom of the form.

8 With the Vendor Ledger Entry data item still selected, bring up the
properties for that data item.

9 Click on the DataItemLinkReference property. Verify that it is set to


Vendor.

10 Change the DataItemLink property to Vendor No.=FIELD(No.).

11 On the main menu, click View, Sections.

12 Insert a Vendor Header section.

13 Change the PrintOnEveryPage property to Yes.

14 Insert a Vendor Ledger Entry Header section.


4-52 Navision Attain Objects

15 Change the PrintOnEveryPage property to Yes.

16 Click on the Vendor body section.

17 From the Field Menu, add the No., Name, and Phone No. fields.

18 Move the labels to the header.

19 Click on the Vendor Ledger Entry body section.

20 From the Field Menu, add the Posting Date, Document Type,
Document No., Description, and Amount fields.

21 Move the labels to the header.

22 Insert a Vendor Ledger Entry footer section.

23 Add the Amount field to the Vendor Ledger Entry footer section.
Delete the label.

24 Line up the Amount field on the footer section with the Amount field
on the body.

25 Change the FontBold property of the Amount field on the footer


section to Yes.

26 Save the report with ID of 91700 and the Name Vendor Detail.

Stage 2

1 Open report 91700 in the Report Designer.

2 Select the Vendor Ledger Entry data item.

3 Change the GroupTotalFields property to Posting Date.

4 Change the DataitemTableView property to SORTING(Vendor


No.,Posting Date,Currency Code).

5 Click View, Sections.

6 Insert a Vendor Ledger Entry group footer section.

7 Add the Amount field to the Vendor Ledger Entry group footer section
and delete the label.
Basic Reports 4-53

8 Line up the Amount field on the footer section with the Amount field
on the body.

9 Close, save and compile the report.

Stage 3

1 Open report 91700 in the Report Designer.

2 Select the Vendor data item.

3 Change the PrintOnlyIfDetail property to Yes.

4 Close, save, and compile the report.

Step 4

1 Open report 91700 in the Report Designer.

2 Select the Vendor Ledger Entry data item.

3 Change the DataitemTableView property to SORTING(Vendor


No.,Posting Date,Currency Code) WHERE(Document
Type=FILTER(<>Credit Memo)).

4 Close, save and compile the report.

The report should now be complete.

Exercise 4.7.1 Using FlowFilters in a Report

Are there any records on the report that are outside of that range?

Yes. The report has not been filtered at all.

Why do you think the report did not change?

The second data item (Cust. Ledger Entry) does not know about the filter
that the user set.

Are there any records on the report that are outside of that range?

No. The report is filtered properly.


4-54 Navision Attain Objects

What happens to the report if you leave the Date Filter empty on the
request form?

All records are shown. No filter is applied.

Exercise 4.7.2 Adding and Taking Away from the Request Form

What tabs appear on the request form?

Customer

What tabs are on the request form now?

Customer, Cust. Ledger Entry

What can the user do on each tab (notice the button)?

They can filter the data item or sort the data item on both tabs.

What tabs are on the request form now?

Customer

What tabs are on the request form now?

Customer, Cust. Ledger Entry

What can the user do on the Cust. Ledger Entry tab ?

They can filter the data item. The sort button no longer appears.

Which two properties determine whether the user sees the tab for a data
item on the request form?

ReqFilterFields, DataItemTableView. The tab will show if there is no sorting


or if there are request filter fields defined. The tab will not show if you sort
the data item and do not define request filter fields.

Adding a Checkbox to the Options Tab

What tabs are on the request form now?

Customer, Cust. Ledger Entry, Options


Basic Reports 4-55

Can you change the value of the checkbox you added?

Yes. It can be checked or unchecked.

What value does the variable have when the box is checked?

True.

What value does the variable have when the box is not checked?

False.

Check the box and preview the report. Close the preview window and rerun
the report. Is the box still checked?

No.

Check the box and preview the report. Close the preview window and rerun
the report. Is the box still checked?

Yes.

Exercise 4.7.3 Skipping Sections in a Report

Does the report look the same as the last time you ran the report?

Yes. It shows all sections.

Close the preview window. Rerun the report and make sure the checkbox
is not checked on the Options tab.

What has changed on the report?

The detail information in the Body sections of the Cust. Ledger Entry data
item no longer show up on the report. In fact, that entire section is not
printing. Only the other Cust. Ledger Entry data item sections are printing
along with the Customer sections.

Exercise 4.7.4 Adding a Grand Total with More Than One Data Item

Does the total at the end of the report seem correct?

Yes.
4-56 Navision Attain Objects

How else might you have done this?

I could have added a global variable and summed the records myself.

Exercise 4.7.5 Adding Multilanguage Functionality to Your Report

When creating new reports or modifying existing reports, caution must be


taken to ensure all data captions on the request form and sections have the
CaptionML and OptionCaptionML populated as shown previously in Basic
Tables. The Name property must remain the number of the control, for
example Control 9.
Basic Reports 4-57

4.11 CHAPTER REVIEW

In this section, you will be asked questions about the material covered in
this chapter. Answers to the questions can be found in the subsection
Answers.

Questions

True or False. All reports must print at least one page.

List the names of the three Designers used with reports and describe their
function.

How many times will a Header section print on a report for an indented data
item (assume PrintOnEvery page is turned off and there is data in the
table)? What if the data item is not indented?

What data item property can be used to remove the data items tab on the
request form (assume there are no request filter fields set)?

What two properties of a data item must be set in order to print a sub total
of a field on a group footer section?

When does a Transheader section print for a data item?

What property can be set to start a new page every time a record is read?

What two properties can be used to print a footer at the bottom of every
page?

Given a report that has two data items and the second is indented. What
C/AL code could you write that would most closely resemble this situation?
4-58 Navision Attain Objects

What property can be used to filter an indented data item based on fields in
the unindented data item above it?
Basic Reports 4-59

Answers

All reports must print at least one page.

False. Some reports do not print anything. They are called processing only
reports.

List the names of the three Designers used with reports and describe their
function.

Report Designer – design the data model for the report.

Sections Designer – design the page layout for the report.

Request Options Form Designer – design the Options tab of the request
form.

How many times will a Header section print on a report for an indented data
item (assume PrintOnEvery page is turned off and there is data in the
table)? What if the data item is not indented?

Once for every record in the data item that it is indented under.

Once for the entire report.

What data item property can be used to remove the data items tab on the
request form (assume there are no request filter fields set)?

DataitemTableView. You must choose a key to sort the data item.

What two properties of a data item must be set in order to print a sub total
of a field on a group footer section?

GroupTotalFields and TotalFields.

When does a Transheader section print for a data item?

Whenever the data item’s body sections fill one page and force a new page
to be created. It does not print if another data item causes the new page.

What property can be set to start a new page every time a record is read?

NewPagePerRecord on the data item.

What two properties can be used to print a footer at the bottom of every
page?
4-60 Navision Attain Objects

PrintOnEveryPage=Yes and PrintInBottom=Yes for the footer section.

Given a report that has two data items and the second is indented. What
C/AL code could you write that would most closely resemble this situation?

Nested loops.
While DataItem1.GetRecord Do
While DataItem2.GetRecord Do
;

What property can be used to filter an indented data item based on fields in
the unindented data item above it?

DataitemLink
Chapter 5.

Basic Dataports

Dataports are used to export data to external text


files, and to import data from external text files.

This chapter contains the following sections:

Dataport Fundamentals

Designing Dataports

Sample Dataports

Chapter Review
Basic Dataports 5-2

5.1 DATAPORT FUNDAMENTALS

Dataports are objects that are used for importing data from and exporting
data to external text files. During importing and exporting, there is a wide
range of options for defining the format of the external file.

When importing, you can control what happens if a record in the import file
has the same value in the key as an existing record in the database table.
In addition, at dataport field level, you can control whether or not to run the
OnValidate trigger for each field.

Dataports can be dynamic, that is, on execution the dataport determines


whether the process is an import or an export and the name of the file to
read from or to be written to. This is achieved either with options that the
user sets in the request form or by programming.

The following diagram shows the components of the dataport object:

Dataport Description

Properties

Triggers

Data Items

Properties

Triggers

Dataport Fields

Properties

Triggers

Request Form

Properties

Triggers

Controls

Properties

Triggers

The diagram shows how a dataport is composed of a number of different


components. The following is a short description of each component.
Basic Dataports 5-3

Dataport Description

This is the complete description of the dataport – how data is collected,


how data is formatted when written to the output file and so on. The
dataport description is stored in the database.

Data Item

A data item corresponds to a table. In order to retrieve information from the


tables in the database, you define data items.

Dataport Field

A dataport field refers to a field in a file from which data is to be imported.


Dataport fields in the external file are defined either as having a fixed
length, or as delimited by certain characters that you define.

Request Form

A request form is a form that is run before the actual dataport begins
execution. It is used to gather requests and options from the user of the
dataport, for example, the name of the external file.

Property

A property is an attribute of an object – dataport, data item, dataport field,


and so forth – that characterizes the object in some way, for example
length and position of a dataport field in a line (when importing). Properties
are set on the Property Sheet of an object.

Trigger

Certain predefined events that happen to a dataport cause the system to


execute a user-definable C/AL function – the event triggers the function. As
you can see in the diagram, the dataport itself, the data items, the dataport
fields, the request form and the controls on the request form all have
triggers. Triggers are edited in the C/AL editor.

Logical Design

Designing a dataport involves two distinct tasks: designing the data model
and defining the layout of the external file.
Basic Dataports 5-4

Data model

You build the data model by designing data items. A data item corresponds
to a table. When exporting data, each data item is iterated for all records in
the underlying table, and you can set up sorting order, keys and table views
to use. For each record, you can decide whether or not it should be written
to the external file.

When importing data, records read from the external file can be inserted in
the table that corresponds to the data item. You can examine the records
before inserting them, and you can specify whether records should be
inserted automatically and whether records already in the database should
be overwritten or updated when a record with the same primary key is read
from the external file (or, of course, whether this record should be inserted
at all).

External file

The layout of the external file is defined by means of a set of dataport


properties. During importing, these properties describe how the input
stream should be broken up into records and dataport fields; during
exporting, these properties describe how the dataport fields and records
should be written to the file.

How a Dataport Is Run

The following flowchart is a simplified version of the full set of dataport


flowcharts in Appendix G, Dataport Flow Charts, in the Application
Designer’s Guide.
Basic Dataports 5-5
Basic Dataports 5-6

When the user initiates the dataport run, the OnInitDataport trigger is run.
This trigger can be used to initialize variables, but should not be used for
general processing purposes.

When the OnInitDataport trigger has been executed, the request form for
the dataport is run if it is defined. Here, the user can choose to cancel the
dataport run.

If the user chooses to continue, the dataport enters a transaction (a BWT –


Begin Write Transaction – is issued) and then the OnPreDataport trigger is
called. At this point, no data has yet been processed.

The OnPreDataport trigger can be used to process the user input from the
request form.

When the OnPreDataport trigger has been executed, the external file is
opened, and the processing of the first data item begins.

When the first data item has been processed, the next (if any) data item is
processed in the same way.

When there are no more data items, the OnPostDataport trigger is called.
You can use this trigger to do any post processing that is necessary.

When the OnPostDataport has been processed, the external file is closed.

The transaction that was entered in step 3 ends with an EWT (End Write
Transaction) being issued.

The processing of each data item (steps 5 and 6) is, of course, different for
importing and exporting. The flow charts in Appendix G show the details.
What is important to note in the overall chart is that the entire processing of
a dataport takes place within a transaction. This means that if the
processing is interrupted at any time before the final EWT, there will be no
trace left of the interrupted run afterwards in the database (an external file
will, however, often have been corrupted.)

Note

The Right and Left buttons on the Dataport Designer window can indent
data items in User Portal dataports. For all other kinds of dataports, you
must process one data item (table) at a time.
Basic Dataports 5-7

Saving, Compiling and Running a Dataport

After you have designed a dataport, you must save and compile it before it
can be run from other objects or from the Object Designer. Normally, you
do this when you have finished designing the dataport. However, you may
want to save a dataport that is not yet finished and thus cannot be
compiled. You can also compile and run a dataport without closing or
saving it.

Saving and Closing a Dataport

A dataport is closed when the Dataport Designer window is closed. You


can close this window in the same ways that you can close any other
window.

To save a dataport:

1 When you close a dataport, C/SIDE will ask whether the dataport
should be saved. If it is a new dataport (a dataport that has not been
saved before) you will have to assign it an ID and a name. The ID
must be unique and follow the rules for numbering objects – your
C/SIDE dealer will provide you with this information.

Hint: If you enter ID and Name as dataport properties, these values will
be used, and you will not be prompted for ID and Name when you
close the dataport.

2 The Compiled option field is by default set to TRUE (displayed as a


check mark). If your dataport is not yet ready to be compiled, remove
the check mark by clicking the field.

3 Click OK to save the dataport.

You can save a dataport without closing it by choosing Save or Save As


from the File menu. By using Save As, you can rename an existing
dataport (note that you can copy a dataport by opening it and saving it with
a new name).
Basic Dataports 5-8

Compiling a Dataport

Dataports, like other objects in C/SIDE, must be compiled before they can
be run. As described above, you can choose to compile a dataport
whenever you save it.

While you are designing a dataport, you may want to test-compile it to find
possible errors. You can test-compile a dataport during design by choosing
the Compile option on the Tools menu.

Running a Dataport

In a finished application, your dataports will be incorporated into menus, or


they will be called, for example, from a command button on a form.
However, while you are designing dataports, you will often want to run
them before they have been integrated into an application.

Test-Running Dataports

While designing a dataport, you can test-run it by choosing Run from the
File menu. In this way, the dataport will be compiled and run in its current
stage of development. It will not be saved, which means that you can use
this function to verify that the changes you are making work as intended
before you save them.

Note

If the dataport is an Import, no records will actually be saved in the


database table during a test-run.

Running Dataports from the Object Designer

You can run a dataport from the list of dataports in the Object Designer by
selecting it and clicking the Run button.
Basic Dataports 5-9

5.2 DESIGNING DATAPORTS

This section provides an overview of the elements of designing dataports.


The tables of properties summarize what each property is used for. Full
(and most up-to-date) explanations are found in the online C/SIDE
Reference Guide.

Designing a dataport consists primarily of setting various properties. The


following sections explain which properties to use, and how to use them.

Dataport Properties

This set of properties describes the dataport in general, and this is also
where you specify the format of the external file.

Note that Import and FileName can be set and reset dynamically. For
example, you can create a dataport where the user can select whether to
import or export, or select the name of the external file to read from or write
to (or you can generate a filename automatically once the dataport is run)

Property Meaning

ID ID of the dataport – must be unique among dataports.

Name Name of the dataport – must be unique among


dataports.

Caption Caption (shown on the request form window, for


example – the default is the same as Name).

Import This property determines whether the dataport


imports or exports data. It can be set dynamically in
the OnPreDataPort trigger. It cannot be changed after
the OnPreDataPort trigger has been run. The default
value <Yes> allows the user to choose import or
export on the Options tab of the request form. The
value Yes or No takes away the choice for the user
and forces either importing or exporting, respectively.

FileName The name of the external file to write data to or read


data from. This property can be set dynamically. If
you reset the file name after a file has been opened,
this file is closed and a new file is opened.

FileFormat Determines the format of the external file: Variable or


Fixed.
Basic Dataports 5-10

Property Meaning

FieldStartDelimiter When FileFormat is Variable, this property is used to


define the string that marks the beginning of a
dataport field on input or output.

FieldEndDelimiter When FileFormat is Variable, this property is used to


define the string that marks the end of a dataport field
on input or output.

FieldSeparator When FileFormat is Variable, this property is used to


define the string that separates dataport fields on
input or output.

RecordSeparator This property is used to define the string that


separates records on input or output.

DataItemSeparator This property is used to define the string that


separates data items on input or output.

UseReqForm This property determines whether the request form


should be run before the dataport itself is run.

ShowStatus This property determines whether a status window will


be shown while the dataport is running. This window
also has a Cancel button that makes it possible to
interrupt the dataport run – which is only possible
otherwise if you create a dialog yourself.

Permissions The permissions of the dataport to access database


objects. (The dataport can have wider permissions
than the individual user, thereby enabling the user to
use dataports that retrieve information from tables
that he or she cannot normally access.)

FileFormat

The FileFormat property determines the format of the external file. This
property defines how a record is read from or written to the file. The
RecordSeparator property defines how the file is broken up into records,
and the FileFormat property then defines how to break each record up into
dataport fields. Finally, the DataItemSeparator property defines how data
items should be separated if the dataport has more than one data item.
Note that data items cannot be nested – although a dataport can have
several data items that are processed sequentially.
Basic Dataports 5-11

FileFormat: Fixed

When the format of the external file is Fixed, the dataport fields in a record
have a fixed width. You can define the starting position and the width of
each dataport field in the record (if the RecordSeparator is a newline
character, you can think of a record as a line of text). The positions and
widths of the dataport fields are properties of the dataport fields (described
in a following subsection).

FileFormat: Variable

When the format of the external file is Variable, the dataport fields in a
record are delimited by characters that you define, and the dataport fields
can have varying widths. The dataport fields are separated by the string
defined as the FieldSeparator property.

The FieldStartDelimiter and the FieldEndDelimiter properties are used to


"quote" the dataport field contents in situations where the data of a dataport
field contains the character that is defined as a separator (FieldSeparator,
RecordSeparator or DataItemSeparator). These delimiters are not
obligatory. This means that if only one dataport field of a record needs to
be quoted, only this dataport field has to be enclosed by the
FieldStartDelimiter and FieldEndDelimiter characters. The other dataport
fields can have the delimiters optionally – it will make no difference during
importing. During exporting, all dataport fields are written to the external file
with all delimiters and separators.

Data Item Properties

This set of properties describes the data items of the dataport, which is the
database table part of the dataport.

Most of these properties are the same and have the same function as the
corresponding properties of a data item in a report (see the Chapter
Designing Reports. Three properties are special for a dataport: AutoSave,
AutoUpdate and AutoReplace.

Property Meaning

DataItemTable Table of item (can be set in the designer when


creating data items).

DataItemVarName Name of record as variable (default is name of


DataItemTable).
Basic Dataports 5-12

Property Meaning

DataItemTableVie The key, sort order and filters to apply.


w

ReqFilterHeading Tab caption for this item on request form (default is


name of DataItemTable).

ReqFilterFields Names of the fields that initially will be included in the


ReqFilter form.

CalcFields Names of the fields that will be calculated after a


record has been retrieved.

AutoSave This property determines whether records that are


imported will be automatically inserted in a C/SIDE
table.

AutoUpdate This property determines whether records that are


imported will be initialized with values from an existing
record with the same primary key.

AutoReplace This property determines whether records that are


imported will automatically replace existing records
with the same primary key.

The three Auto* properties determine how records that are read from the
external file are handled. They are also used to resolve the conflict that
arises when a record that has been read from the external file during
importing has the same primary key as a record that already exists in the
database table.

AutoSave and AutoReplace are used to define how records are saved in
the database table.

Note that if AutoSave is No, the settings of AutoReplace and AutoUpdate


have no effect – in this case you have to handle any conflicts from your
C/AL code.
Basic Dataports 5-13

The following table outlines the effects that the various combinations of
settings for these properties have:

Auto Auto Auto Record exists in Record exists only


Save Update Replace database and in in import file
import file
No* --- --- The record in the The import record is
database is not not automatically
automatically updated inserted in the
or replaced database

Yes No No A runtime error will be The import record is


provoked, and the automatically inserted
import is terminated in the database

Yes No Yes The import record will The import record is


replace the existing automatically inserted
record in the database

Yes Yes --- The import record will The import record is
update the existing automatically inserted
record in the in the database
database

--- means that the setting doesn’t matter

* If AutoSave is No, it is possible to insert and modify records by using


insert or modify from C/AL

AutoUpdate is useful in some particular situations. Its functionality is best


explained by a brief example:

Suppose you have a table that is an item list. You update the prices by
exporting a list with item numbers (the primary key) and prices to an
external file and then you do some calculations on the prices on a
spreadsheet. Now, when the prices are calculated and you are ready to
import the file with the new prices, it is obvious that the records read from
the external file will have the same primary key as records that are already
in the database. Using AutoSave and AutoReplace will not solve the
problem. If you are replacing every record with the corresponding record
from the import file, all the information except the item numbers and the
prices will be lost (it is assumed that the table contains information other
than the item numbers and the prices, for example names of the items,
stock level, and so forth).

AutoUpdate solves this dilemma. When a record is imported, it actually


Basic Dataports 5-14

replaces the existing record – but fields that are not present in the imported
record are initialized with the data from the already existing record instead
of being left empty. The existing record is updated with the information that
was revised.

Dataport Field Properties

This set of properties describes the dataport fields of a record. If FileFormat


is Fixed, you use the StartPos and Width properties of each dataport field to
define how a record that is read from the external file is to be broken into
dataport fields. During exporting, these properties determine how data from
the database is written to the external file.

Property Meaning

Enabled Determines whether the dataport field should be


enabled or disabled. A dataport field that is disabled is
imported from the external file, but will not be inserted
into the record.

SourceExpr The source expression of the dataport field. During


importing, this could be the name of the database
table dataport field where the value that is read from
the external should be stored, but it can be any valid
C/AL variable. During exporting, this could be the
value that is exported to the external file – for
example the name of a database table field, but it can
be any valid C/AL expression.

StartPos If FileFormat is Fixed, this is the starting position of


this dataport field. Positions are numbered from 1
upwards.

Width If FileFormat is Fixed, the width of this dataport field.

CallFieldValidate Determines whether the OnValidate trigger will be


executed when the dataport field is imported.

Format Describes how the dataport field will be formatted


during exporting. For example, you can determine the
number of decimal places, and so forth.

When fields are exported, the data is converted to text before the export. If
the format is Fixed and the Width is smaller than the actual width of the
data after conversion, the contents will be truncated from the right until it
has the defined Width. That is, a number is not rounded or truncated as a
Basic Dataports 5-15

number, but as text – from the right.

You will get a warning at design-time if you have defined dataport fields
with starting positions and widths that could cause these dataport fields to
overlap. The error will make it impossible to compile (and thus to execute)
the dataport.

You can, however, have gaps in the dataport fields (the starting position of
the second dataport field does not have to be exactly where the first
dataport field stopped). These gaps may skip unneeded information or
create blank columns in the file.

During importing, a value that is too large for the data type or defined width
of the database table field where it is to be inserted will cause an error and
execution will stop. As the whole dataport is inside a transaction, no traces
will be left of the aborted run in the database.
Basic Dataports 5-16

5.3 SAMPLE DATAPORTS

This section tells you how to create dataports by going through the steps
necessary to create the four fundamental types of dataports: importing and
exporting, each with a fixed and a variable format of the external file.

Exercise 5.3.1 Exporting - Fixed Format

This sample dataport will export records to a file in fixed format. The
records in the file will be separated by new lines, and within each record
(line, in effect), a dataport field will have the same width in all records, no
matter how wide the actual data of the dataport field is.

The database table that will be used as an example is the G/L Account
table (the Chart Of Accounts). There are several FlowFields among the
dataport fields that are exported, which have to be calculated when
exporting.

Simple Version

The first version is very basic. It will be extended to a more refined object in
the next subsection.

1 Open the Object Designer.

2 Click Dataport, New.

3 C/SIDE opens the Dataport Designer. Select the first DataItem field
and select the G/L Account table from the lookup form that you open
by clicking the Lookup button. The Name is set by default to the name
of the table. You do not have to change it in this dataport.
Basic Dataports 5-17

4 Open the Property Sheet for the dataport (not for the data item). To do
this, click View, Properties while the dataport is selected (you can
select the dataport either by clicking in an empty line in the Dataport
Designer, or by using Edit, Select Object.

5 Set these properties:

Import – set it to No to create a dataport that exports data.

FileFormat – set it to Fixed.

The remaining properties can be left at their default settings.

6 Select the G/L Account data item by clicking it in the Dataport


Designer.

7 Click View, Dataport Fields and the Dataport Field Designer opens.

8 In the Dataport Field Designer, click View, Field Menu and the Field
Menu window opens.

9 Select the fields to be exported. Here, the fields No., Name, Balance
at Date and Net Change have been selected. You may have to scroll
the Field Menu window in order to select these fields, depending on
how the Field Menu window is currently sized.
Basic Dataports 5-18

10 Click the Dataport Field Designer to add the fields you have just
selected in the Field Menu window. (You cannot click OK in the Field
Menu window.) You will be asked if you want to append the selected
fields.

11 Click Yes.

12 Go to the Property Sheet of the G/L Account data item.

Select the CalcFields property, click the AssistButton to open the Field List
window. Then, select those fields from the data item that must be
calculated when they are exported,that is, the FlowFields. In this case, it is
the Balance at Date and Net Change fields. Click OK to close the Field
List window.
Basic Dataports 5-19

Now, you are ready to run the dataport. You can run it before saving it by
clicking File, Run. If you want to save the dataport first, you will be
prompted for a name and a number as with other objects.

About Inserting Dataport Fields

When the dataport fields have been inserted from the Field Menu, you can
check the settings of the StartPos and Width properties of all the fields in
the Dataport Field Designer form (accessed by clicking View, Dataport
Fields). They look like this:

As you can see, both StartPos and Width have been filled out for you. They
are assigned values according to these rules:

Datatype of field Width assigned

Code If actual length > 10, actual length is used, otherwise 10

Text If actual length > 30, actual length is used, otherwise 30

Date 11

Time 10
Basic Dataports 5-20

Datatype of field Width assigned

Option 10

Decimal 12

Integer 7

Boolean 10

Running the Dataport

When you run the dataport, you will see the default request form. The first
tab is of little interest, but the second one, Options, is important. Here you
can state the name of the external file to write to.

When you have stated the name of the file, click OK to run the dataport.
The default status window will show you the progress. When the run is
over, you can look at the file in a text editor:

Refined Version

This simple dataport could be more user-friendly. Depending on what the


dataport is to be used for, several things could be changed. The following
are examples of what you can do:

• The first tab in the request form should not be shown, as we do not
want the user to set filters and keys.

• Only accounts where the Account Type is Posting or End-Total should


be exported.
Basic Dataports 5-21

• The numbers must be formatted as thousands. There must be no


thousand separators, no decimals and the sign should be prefixed.

Changing the Request Form

You must not set the UseReqForm property to No in order to remove the
request form. Doing this will make it impossible for the user to set the name
of the file that the data should be written to. In fact, since no filename has
been set, the dataport will provoke a runtime error.

Instead, you can select the Options tab and remove the data item tab by
setting a DataItemTableView for the data item. When this property is set –
as opposed to being left undefined – the user cannot change key or sort
order and cannot set a table filter, and the corresponding tab will be
removed by the system.

1 Open the Property Sheet for the data item.

2 Click the AssistButton in the DataItemTableView property to open this


form:

3 Fill out at least one of the fields. In the preceding picture, Key has
been set to No. and Order has been set to Ascending.

Selecting Specific Account Types

In order to select only some account types you must set a table filter. This
can be done in the DataItemTableView property. Continue from step 3
above:

4 Click the AssistButton in the Table Filter field to open the following
form:
Basic Dataports 5-22

5 Set the values of Field, Type and Value fields as shown in the
preceding picture. This creates a table filter that will select records
where Account Type is Posting or End-Total (the character between
the two values is a | (pipe) which means OR.)

6 Click OK to close the Table Filter form and the Table View form.

Changing the Formatting of Numbers

To export the decimal fields, Balance at Date and Net Change as


thousands (so that the number 1.444.723,67 is exported as 1444), you
have to use the SourceExpr property of these fields:

7 Go to the Property Sheet of both the Balance at Date and Net


Change dataport fields.

8 Enter this expression as the SourceExpr property of the first dataport


field:

FORMAT(ROUND("Balance at Date"/1000,1,'='),0,1)

In the C/AL statement, the Balance at Date field is first divided by


1000. The result is rounded by the ROUND function, and then
FORMAT is used to render the return value from ROUND in format 1
(which for a decimal value means <Sign><Integer><Decimals>).

9 Enter this expression as the SourceExpr of the second dataport field:

FORMAT(ROUND("Net Change"/1000,1,'='),0,1)
Basic Dataports 5-23

The file that is created by this dataport could look like the following
imported into a spreadsheet:

Exercise 5.3.2 Exporting - Variable Format

This sample dataport will export the same records as the previous
example, but in a variable format. Each dataport field in a record will be
delimited by characters that you define and will only have the width of the
actual data of the dataport field in each of the records.

Very few changes are required to create this dataport instead of the
dataport with fixed width format. You must specify the right set of options
for the data item, as follows:
Basic Dataports 5-24

The FileFormat property is set to Variable, and the FieldSeparator property


is set to ; (semicolon). The FieldStartDelimiter and FieldEndDelimiter
properties are both set to <None>. The RecordSeparator and the
DataItemSeparator properties have been left at their default settings, which
means that records will be separated by newlines, and data items by two
newlines (which is not of real interest here, because we have only one data
item in this dataport.)

The exported file could look like the following in a text editor:

The semicolon was used as FieldSeparator because the dataport fields


include both space characters and commas. Another solution would have
been to use the delimiters – in that case, the FieldSeparator could also
have been a comma, but what you choose should really depend upon the
target application for the exported file, and which formats that application
supports when it is importing text files.

Exercise 5.3.3 Importing - Fixed Format

Creating a dataport that imports data is not very different from creating one
that exports data. You must, however, take into consideration how the
imported records should be inserted in the database table that lies under
the data item. This is especially relevant if the table already contains
records with the same primary key as some of the records to be imported
will have.

This first example assumes that the table is empty (or that other actions
Basic Dataports 5-25

have been taken to ensure that no conflicts will occur).

The file that we are going to import records from, look as follows in an
editor:

In this case, we will import the records into a newly created table. The table
has this layout:

This means that we must decide how the lines in the import file – each line
will become a record in the data item – will be broken down into dataport
fields. The lines have a fixed format, and by carefully looking at the layout
of the lines, these field starting positions displayed in the bottom line can be
deduced:
Basic Dataports 5-26

First Field Second Field Third Field


This tells us that the dataport fields must have the following properties:

Dataport field StartPos Width

No. 1 3

Name 4 11

Price 15 6

Once it has been established how the lines in the import file are organized,
creating the dataport is straightforward:

1 Create a dataport as described earlier.

2 Set the Import property to Yes and the FileFormat property to Fixed.

3 In this example, the preceding table is used. A data item must be


created for this table.

4 Add all the fields from the table to the dataport by using the Dataport
Field Designer and the Field Menu as described earlier. At this point,
the dataport fields will be set up with sizes (and corresponding starting
positions), as deduced from the table design.
Basic Dataports 5-27

It will look like this:

5 You must change the setting of StartPos and Width to the values that
are appropriate for the actual file you are going to import data from. In
this example, the values should be set as follows (as described
earlier):

6 The dataport can be run. Remember that if you run it from inside the
Dataport Designer (by clicking File, Run), the records will not be
stored in the database (in order to have them stored, you must run the
dataport from the Object Designer, or call it from a menu.) You may
also want to remove the unnecessary tabs from the request form.

After running the dataport so that records actually are imported into the
database, the table will look like this:
Basic Dataports 5-28

Note that because Field No. is the primary key of the table, the records are
displayed in an order determined by this field – which, incidentally, is not
the same order as they appeared in the import file.

Possible Errors

It is easy to make errors when deciding how to "cut up" the lines in the
import file. In some cases, this will give a runtime error when the dataport is
run. Consider, for example, if we made an error in setting up the Field No.
dataport field so that it had been assigned a width that is one character too
wide. For most of the import file, this would make no difference at all – the
resulting trailing space would be ignored. But the line beginning with
"112Oven..." would provoke a runtime error when C/SIDE read 112O
instead of 112. The "O" (upper case "o") cannot be inserted into an integer
field.

You might consider it fortunate that the error actually provoked a runtime
error. In other cases, the error might not have been detected by C/SIDE, for
example, if the "cut" between two text fields was placed incorrectly. If you
have the opportunity, test your imports carefully before using them for
production.

Hint

In some cases, the order of the fields you want in your table does not
correspond to the order of the dataport fields in the import file. If this is the
case, you can just design the dataport fields to reflect the order that you
need, by adding the fields individually. You will have to set the StartPos
and Width manually.
Basic Dataports 5-29

Exercise 5.3.4 Importing - Variable Format

Changing the importing dataport to deal with an external file in variable


format is not very difficult. Suppose the file looks like this:

The data is exactly the same as in the file with fixed format which we
imported from above, but here the dataport fields are separated by
commas. The only differences in creating the dataport are:

1 Set FileFormat to Variable.

2 Set FieldSeparator to a comma.

3 Set the delimiters to <None>.

The properties of the dataport should look like this when you have finished:

These are the only differences between the fixed format dataport and
variable format dataport. The result of running this dataport will be the
same as running the dataport with a fixed format.
Basic Dataports 5-30

Note

If the order of the dataport fields in the import file is different from the order
of the dataport fields in the data item, you cannot use the same method to
move the dataport fields around as you would if the file had a fixed format.
Instead, you can change the order of the dataport fields in the Dataport
Field Designer.

Suppose the import file had the following format instead:

Suppose the table has this layout (same as before):


Basic Dataports 5-31

In this case, you can add the dataport fields in the Dataport Field Designer
in the order in which they appear in the import file:

Note that because the dataport fields have been added one-by-one from
the Field Menu (instead of all-at-once), StartPos and Width have not been
calculated by the designer. It does not matter, however, because these
properties are not used in a dataport with a variable format.
Basic Dataports 5-32

5.4 CHAPTER REVIEW

In this section, you are asked questions about the material covered in this
chapter. Answers to the questions can be found in the subsection Answers.

Questions

1 What is different between the description of a report and the


description of a dataport?

2 What can you not do with a data item in a dataport that you could do
with a data item in a report?

3 The dataport fields that you create in the Dataport Field Designer must
match what for an import dataport?

4 In an import dataport, if you set AutoSave to No and AutoUpdate to


Yes, what will the dataport do with the records from the file?

5 When must you use the StartPos and Width properties of a dataport
field?

6 True or False. Every dataport field must be bound to a real field in the
data item.

7 What does the Calcfields property do on a data item?

8 When exporting, which dataport file type lines up the information in


columns?
Basic Dataports 5-33

9 When exporting, which dataport file type creates the smallest possible
file?

10 When importing, which dataport properties can you set so that the
user does not see the options tab?
Basic Dataports 5-34

Answers

1 What is different between the description of a report and the


description of a dataport?

Instead of sections, the dataport has dataport fields.

2 What can you not do with a data item in a dataport that you could do
with a data item in a report?

Indent data items.

3 The dataport fields that you create in the Dataport Field Designer must
match what for an import dataport?

The file that you are trying to import.

4 In an import dataport, if you set AutoSave to No and AutoUpdate to


Yes, what will the dataport do with the records from the file?

Nothing. If AutoSave is set to No, the dataport will not insert or modify
any records automatically.

5 When must you use the StartPos and Width properties of a dataport
field?

If the file type is Fixed.

6 True or False. Every dataport field must be bound to a real field in the
data item.

False. Dataport fields can be bound to variables or other fields in


record variables (for exporting other values are also acceptable).

7 What does the Calcfields property do on a data item?

It tells the dataport to calculate the values of FlowFields that are to


exported.

8 When exporting, which dataport file type lines up the information in


columns?

Fixed.

9 When exporting, which dataport file type creates the smallest possible
file?
Basic Dataports 5-35

Variable. There are no extra spaces between dataport fields.

10 When importing, which dataport properties can you set so that the
user does not see the options tab?

Filename property to the name of the file (the user cannot change
it).Import to Yes (the user cannot change it). The options tab
disappears.
Chapter 6.

Basic Codeunits

This chapter explains what a codeunit is and how


to create one. It also shows you how to use the
functions in a codeunit from other application
objects.

This chapter contains the following sections:

A C/SIDE Codeunit

Creating Codeunits

Using Codeunits

Chapter Review
6-2 Navision Attain Objects

6.1 A C/SIDE CODEUNIT

You may have seen examples of C/AL code in forms and reports. In fact,
C/AL code can be stored in a form, report, or other object. In simple
applications, the normal approach is to place the code in the object that
calls the functions, but as your application grows you will often find that you
use the same functions repeatedly. Instead of declaring the same functions
over and over again, it would be useful if you only had to define them once.
This is where the codeunit becomes useful. Think of a codeunit as a
container for C/AL code that you want to use in many application objects. In
codeunits you can define:

Functions

A function is a sequence of C/AL statements, which you define in order to


create new functionality. Within each function, you can define local
variables, that is, variables whose scope is limited to the function in which
they are defined.

Global Variables

A global variable is a variable whose scope covers all the functions in the
codeunit.

Temporary Tables

A temporary table is a table that is not stored in the database. Temporary


tables are mainly used as structured variables that hold data temporarily
while you work on it. Refer to Defining and Using a Temporary Table on
page 93 for a description of how to create a temporary table.

In a codeunit you can


store general functions
that are not directly
associated with any of
your other application
objects
Basic Codeunits 6-3

Each function you add to a codeunit will be shown in a separate section


when you view the file in the C/AL editor.

All codeunits include two default triggers called Documentation and OnRun.
In the Documentation section, you can add optional information about the
code such as the purpose of the codeunit, a version number and so on. In
the OnRun section, you can include code that you want the system to
execute when the codeunit is run.

Note

Codeunits contain functions but can also be run. Besides being a container
for functions that can be run individually, a codeunit can itself be run by
writing <CodeunitVariableName>.Run. When you run a codeunit, it is
the code in the OnRun section of the codeunit that will be run.
6-4 Navision Attain Objects

6.2 CREATING CODEUNITS

You create a new codeunit or modify an existing codeunit in the same way
you create and modify other application objects, that is, by using the Object
Designer.

To create a codeunit:

1 Click Tools, Object Designer to open the Object Designer.

2 Click Codeunit in the Object Designer.

3 Click New to create a new codeunit. C/SIDE will open the C/AL editor,
where you can create functions.

To modify an existing codeunit:

1 Click Codeunit in the Object Designer.

2 Select the codeunit you want to modify.

3 Click Design and C/SIDE will open the C/AL editor, where you can
modify the codeunit by changing existing functions or adding new
functions.

Using the C/AL Editor

The C/AL editor is where you view and edit your code. This editor is
designed to make it easy for you to create and modify C/AL code. When
you are in the editor, you have access to the C/AL Symbol Menu that helps
you define C/AL functions. When you use the C/AL Symbol Menu, you can
get help about all C/AL functions. Select the C/AL function name in the
column to the right and press F1.
Basic Codeunits 6-5

When you create a codeunit, the window shows the two default sections
described above (the Documentation and the OnRun section).

From the Object Designer you can open as many codeunits as you like.
Each time you create a new codeunit or open an existing one, it will be
displayed in a separate window. This makes it easy to cut and paste lines
of code between the codeunits.

If you have tried to use other Windows editors, you’ll find the C/AL editor
easy to use. You can access the editing functions both from the Edit menu
and from the toolbar.

Use the Cut, Copy and


Paste functions to edit the
C/AL code.

Write documentation for


the codeunit here.

Add your own functions


here

Paste

Cut Copy
6-6 Navision Attain Objects

When you work in the C/AL editor, you can use a number of shortcut keys:

To... Press...

cut the selected text to the clipboard CTRL+X

copy the selected text to clipboard CTRL+C

paste the text at the clipboard into CTRL+V


the codeunit at the cursor position

Defining Variables and Functions in Codeunits

When you have created a new codeunit, the next step is to define the
global variables and functions you need in the codeunit. You use the C/AL
Globals tool for this.

To access the C/AL Globals tool:

1 Make sure that focus is on the C/AL editor. Click View, C/AL Globals
and C/SIDE displays the C/AL Globals window:

2 In the C/AL Globals window, you select whether you want to add a
global variable or a function.

To add a global variable:

1 Click the Variables tab in the C/AL Globals window.

Add a name and a type. If the type you select corresponds to an application
object, you also have to add a subtype, that is, the name of a specific
object in the database. If you select text or code, you have to define a
Basic Codeunits 6-7

length for the variable (the default length is 10 characters for code, and 30
for text). If you select OCX or Automation, you also have to add a subtype.

To add a function:

1 Click the Functions tab in the C/AL Globals window. C/SIDE will
display:

2 Enter a name for each function you want to add.

3 Press Locals to define the parameters, return value and local


variables for each function. C/SIDE will display the C/AL Locals
window:

4 For each parameter you have to specify the calling method, a name,
and a data type. You can specify a subtype and a length, but this is
optional.

The calling method can be specified as Var, which means that the
6-8 Navision Attain Objects

parameter is passed by reference rather than by value. The value of a


variable can only be changed by a function when it is passed to the
function by reference. When the parameter is not specified as Var,
only a copy of the variable is passed to the function. If the function
changes that value, the change affects only the copy and not the
variable itself.

If the type you select corresponds to an application object, you also


have to add a subtype, that is, the name of a specific object in the
database. If you select text or code you have to define a length for it
(the default length is 10 characters for code, and 30 for text).

5 Click the Return Value tab to define the return value for your new
function.

6 Enter a name for the return value and select a data type from the
drop- down list in the Return Type field. You can also select a length,
but only if the type is text or code.
Basic Codeunits 6-9

7 Click the Variables tab in order to define local variables. C/SIDE


displays:

8 For each local variable, you must add a name and a type. If the type
you select corresponds to an application object, you also have to add
a subtype, that is, the name of a specific object in the database. If you
select text or code, you have to define a length for the variable (the
default length is 10 characters for code, and 30 for text).

Using the C/AL Symbol Menu

When you write C/AL code in the editor, you can use the C/AL Symbol
Menu to get an overview of:

• All variables defined in the codeunit.

• All C/AL functions.

The information in the C/AL Symbol Menu is divided into columns. The
column to the left shows variable names (if you have defined any) and
function categories. The second column shows the sub-categories, and the
third column (to the right in the picture below) shows the functions in the
category you have selected. You can see the syntax in the bottom of the
window, and you can click OK or Apply to make C/SIDE insert this string in
the C/AL editor.
6-10 Navision Attain Objects

In some cases–for example, when a control on a form is a subform or when


a field is a BLOB field–there are more than three columns. You can use the
right-arrow button to scroll the symbol menu columns to the right (and the
left-arrow button to scroll them back).

If you use the OK button, the Symbol Menu window is closed


automatically; it stays open if you use the Apply button.

If you need help about any of the C/AL functions shown in the column to
the right, put the focus on the function name and press F1 to activate the
context- sensitive online C/SIDE Reference Guide.

Compiling and Saving Codeunits

Before the functions in a codeunit can be run, the code has to be compiled
and saved. When you compile the code, the system checks the syntax of
the statements. If the compiler finds any errors in the code it will display a
message.

To compile the code in a codeunit:

1 Click Tools, Compile.

2 If the system finds any errors in your code it will display a message.
Correct the errors and click Compile again.
Basic Codeunits 6-11

To save the codeunit:

1 Click File, Save and C/SIDE displays:

Enter an ID number and a name. The number is used as a unique


identification, while the name serves as a label. If you save the codeunit
without compiling it, you won’t be able to run it or call any of its functions.

Note

Why Save without Compiling? If you are working on a large and


complicated codeunit, you will want to save your work at regular intervals,
even though it is not yet finished and cannot yet be compiled. In this case,
you have to remove the check mark from the Compiled box before you
save.
6-12 Navision Attain Objects

6.3 USING CODEUNITS

When you use codeunits, you eliminate the need to duplicate code and at
the same time make the code easier to maintain. If you use the same code
repeatedly in your forms or reports, you should create a function in a
codeunit. When you have created a function in a codeunit you can access it
as:

<CodeunitVariableName>.<FunctionName>

Example

Assume that you have created a codeunit containing two statistical


functions named F and G. The illustration below shows how to access
these functions from a form.

Codeunit named StatisticsFunctions

F(x:integer)
Begin
...
End

G(x:integer)
Begin
...
End

Any form
(Global variable StatFun declared as codeunit with subtype of
StatisticsFunctions)

...

Result := StatFun.F(3425) + StatFun.G(346);

...
Basic Codeunits 6-13

This method is generally applicable. That is, from any application object
you can access functions in other application objects by prefixing the
function name with the name of the application object containing the
function.

You can access codeunits through codeunit variables - either by explicitly


declaring a variable with the data type codeunit or by setting the RunObject
property on forms to a codeunit. A codeunit variable does not contain a
codeunit, but only a reference to a codeunit. More than one codeunit
variable may refer to the same codeunit. This is illustrated by the following
figure:

Codeunits contain internal variables that are defined as global variables.


These variables are not accessible directly from code outside the codeunit,
but they can be accessed through user-defined functions on the codeunit.

Whenever a codeunit variable is used for the first time, a new instance of
the codeunit is created, that is, a new set of internal variables is initialized
so that different codeunit variables use different sets of internal variables.

Codeunit Assignment

Codeunits can be treated as objects - one codeunit variable can be


assigned to another codeunit variable, which creates a new reference to
the same codeunit instance. In other words, the codeunit variables then
use the same set of internal variables.

Example

Codeunit 50000 has two functions Set and Get. Set sets an internal
variable to the value of the parameter given. Get returns the value of the
internal variable.
6-14 Navision Attain Objects

VAR
CoMIC1: Codeunit 50000;
CoMIC2: Codeunit 50000;

//codeunit 50000 is a standard codeunit


BEGIN
CoMIC1.Set(1);
CoMIC2.Set(2);
//both codeunit variables are instantiated - they
have
//different instances

CoMIC1.Get();
CoMIC2.Get();
//CoMIC1 returns 1; CoMIC2 returns 2

CoMIC2 := CoMIC1;
//CoMIC2 is assigned to CoMIC1 and they now both use
//the same instance

CoMIC1.Get();
CoMIC2.Get();
//both codeunit variables return 1
END;

CLEAR on Codeunits

When you use the function CLEAR on a codeunit variable that has a
reference to a codeunit instance with two or more references, CLEAR only
deletes the reference to the codeunit and not the actual codeunit instance.
In other words, the codeunit stays intact and can still be used by other
codeunit variables that may have been assigned a reference to this
codeunit. To delete a codeunit instance, you must clear all references to
the codeunit with the function CLEAR. If you need to clear the internal
variables in a codeunit, you must call CLEARALL from a user-defined
function within the codeunit. When a local codeunit variable goes out of
scope, meaning that it is no longer used by the codeunit, it is automatically
cleared.

Single Instance Codeunit

In some cases, the situation requires that only one instance of a codeunit
exist. This means that all codeunit variables of a particular codeunit will use
Basic Codeunits 6-15

the same set of variables. By setting the SingleInstance property for the
codeunit to Yes, all codeunit variables of that codeunit will use the same
instance, thus allowing the developer to create global variables.

Note

It is recommended that you avoid using global variables for most types of
code. However, in certain situations, it may be necessary to use them, for
example, to make sure that you are only using one instance of an external
variable.

A single instance codeunit is instantiated when you use it for the first time.
Normal codeunit instances (codeunits that do not have the SingleInstance
property set) are deleted whenever the last codeunit variable that uses that
codeunit instance goes out of scope. However, single instance codeunits
remain instantiated until you close the company.

Example

Codeunit 50001 has two functions Set and Get. Set sets an internal
variable to the value of the parameter given. Get returns the value of the
internal variable. Codeunit 50001 has the SingleInstance property Set.

VAR
CoSIC1: Codeunit 50001;
CoSIC2: Codeunit 50001;

//codeunit 50001 is a single instance codeunit


BEGIN
CoSIC1.Set(7);
//a codeunit instance is created if one did not exist

CoSIC2.Get();
//returns 7 - CoSIC2 uses the same instance as
//CoSIC1, so they use the same internal variables
END;

Note

It is possible to use a single instance codeunit across objects and not only
within the same object.
6-16 Navision Attain Objects

Limitations on Codeunits

Global variables and temporary tables in a codeunit cannot be accessed


directly from other application objects. The only way to access these values
is through the functions you have created in the codeunit.

All C/AL functions can be used in a codeunit. Notice, however, that you
cannot create a function with the same name as a built-in function. Neither
can two or more user-defined functions have the same name (unless they
are part of different application objects).

Special Considerations for Navision Application Server

In order to fully utilize Navision Application Server, Codeunit 1 must be


modified. When Navision Application Server starts up it normally looks for
the trigger with an ID of 99 in Codeunit 1. Note that User Portal Application
Server looks for the trigger with an ID of 98. When Navision Application
Server is started there is a parameter that is passed to the codeunit trigger,
which is always executed The parameter is in the form of a string, with a
maximum length of 1024 characters, and the interpretation of the string is
the responsibility of the C/AL programmer. If you do not supply the
parameter, the Navision Application Server startup procedure fails.
Basic Codeunits 6-17

6.4 CHAPTER REVIEW

In this section, you will be asked questions about the material covered in
this chapter. Answers to the questions can be found in the subsection
Answers.

Questions

1 What triggers are available in every codeunit?

2 What key can you press to open the Symbol Menu?

3 To call a function in a codeunit from another object, what must be


done first?

4 Can two codeunit variables refer to the same instance of a codeunit?

5 Can two codeunit variables declared in the same object refer to


different instances of a codeunit?

6 How would you change a codeunit variable to point to the same


instance of a codeunit as another codeunit variable?

7 What function can you use to make a codeunit variable point to a new
instance of a codeunit?

8 If a codeunit is designed as a single instance codeunit, can two


codeunit variables refer to different instances of that codeunit?
6-18 Navision Attain Objects

9 How would you address a global variable of a codeunit from an object


that has a variable, called CU, for that codeunit?

10 Can you create a function called Power in a codeunit?


Basic Codeunits 6-19

Answers

1 What triggers are available in every codeunit?

Documentation – for documenting the codeunit.

OnRun – called if you run the codeunit.

2 What key can you press to open the Symbol Menu?

F5

3 To call a function in a codeunit from another object, what must be


done first?

You must create a variable for the codeunit with the correct subtype.

4 Can two codeunit variables refer to the same instance of a codeunit?

Yes.

5 Can two codeunit variables declared in the same object refer to


different instances of a codeunit?

Yes.

6 How would you change a codeunit variable to point to the same


instance of a codeunit as another codeunit variable?

Assignment

CU1 := CU2;

7 What function can you use to make a codeunit variable point to a new
instance of a codeunit?

CLEAR(CU1);

8 If a codeunit is designed as a single instance codeunit, can two


codeunit variables refer to different instances of that codeunit?

No.
6-20 Navision Attain Objects

9 How would you address a global variable of a codeunit from an object


that has a variable called CU for that codeunit?

You cannot address global variables within a codeunit directly from


outside the codeunit. You would have to add functions in the codeunit
that returned or changed the value of the variables.

10 Can you create a function called Power in a codeunit?

No. Power is already a built-in function.


I Course Test

Appendix A.

Course Test

This appendix gives you a chance to measure what you have learned. It
contains questions from every chapter of the course. You can find the
answers in Appendix B.

QUESTIONS
1 Which of the following objects cannot be created in C/SIDE?

a) Tables

b) Forms

c) Reports

d) Code Groups

2 True or False. C/SIDE is an object oriented programming


environment.

a) True

b) False

3 A Table description is made up of Fields and what?

a) Indexes

b) Table Relations

c) Dataports

d) Keys
II Course Test

4 Which of the following properties is be available for a normal code


field?

a) CharAllowed

b) Length

c) Calcformula

d) Data Type

5 Which property would you use to prevent a user from pasting records
into a table?

a) AllowCutPaste

b) PastIsValid

c) UserPaste

d) A user cannot paste records into a table from the clipboard.

6 Which property would you set to prevent a user from editing a field?

a) Editable

b) Enabled

c) AllowUserEdit

d) AllowModify

7 When you run a table from the Object Designer, what is displayed?

a) Raw data from the table.

b) The table object.

c) The fields and keys in a table.

d) A form that displays the data in the table.


Course Test III

8 The primary key in a table is used for what?

a) Sorting

b) Keeping each record unique.

c) Defining the default lookup form for the table.

d) Both a and b.

9 A secondary key in a table is used for what?

a) Sorting

b) Possibly, keeping each record unique.

c) Defining the default lookup form for the table.

d) Both a and b.

10 True or False. The user can only use the primary key on forms.

a) True

b) False

11 Relating two tables in a “one to many” relationship requires…

a) Changing both tables to point to the other.

b) Relating a field in the “many” table to a field in the “one” table.

c) Changing the table properties of the “many” table.

d) Both b and c.
IV Course Test

12 True or False. A conditional table relation can relate its table to more
than one other table.

a) True

b) False

13 What happens when you change the primary key of a record that has
other records in other tables related to it?

a) The values in the other tables change as well.

b) Those other records are orphaned.

c) The other records are deleted.

d) An error occurs.

14 What is required for a Sum FlowField to calculate properly?

a) Data in both tables being summed.

b) A ReqFilterField.

c) A SumIndexField.

d) A FlowFilter.

15 What is required for an Exist FlowField to calculate properly?

a) A SumIndexField.

b) A FlowFilter.

c) A boolean data type to put the value of the CalcFormula in.

d) Nothing.
Course Test V

16 What makes FlowFields and FlowFilters unlike all other fields?

a) They are decimal.

b) They always have a SumIndexField.

c) The data type is FlowField.

d) They are not stored in the table.

17 What would you name a master table that holds Book Information?

a) Book

b) Books

c) Book Info

d) TblBook

18 What would you name a subsidiary table that holds Address


information for customers?

a) Address

b) Addresses

c) Customer Address

d) Customer Addresses

19 A document is represented by what kinds of tables?

a) A Header table.

b) A Lines table.

c) A Header and a Lines table.

d) Document and Document History tables.


VI Course Test

20 What is the name of the primary key field(s) of a Ledger table?

a) Entry No.

b) Customer No., Entry No.

c) Line No.

d) Customer No., Line No.

21 What property of a form binds it to a table?

a) TableNo

b) TableID

c) SourceTable

d) BoundTable

22 True or False. It is better to start all forms with the form wizard.

a) True

b) False

23 What is the property that you must set on a data control?

a) Lookup

b) SourceExpr

c) Drilldown

d) DataField
Course Test VII

24 Card forms…

a) Display one record from a table.

b) Have tabs across the top.

c) Are used for editing records.

d) All of the above.

25 Tabular forms…

a) Display many records from a table.

b) Have tabs across the top.

c) Are always non-editable.

d) All of the above.

26 A tablebox can usually be found on a

a) Tab of a Card form.

b) The center of a Card form.

c) Tab of a Tabular form.

d) The center of a Tabular form.

27 True or False. Option fields can be displayed using a Textbox or


Option buttons.

a) True

b) False
VIII Course Test

28 What type of button would you usually add to the bottom of a card
form?

a) Command Button

b) Menu Button

c) Option Button

d) You don’t, the wizard adds all the buttons for you.

29 What can you use to easily add fields to a form?

a) Field Menu

b) C/AL Editor

c) Menu Designer

d) Symbol Menu

30 What control allows you to display one form within another form?

a) Tablebox

b) Textbox

c) Matrixbox

d) SubForm

31 What name would you use for a Tabular form that displays information
from the Book table?

a) Book

b) Books

c) Book Card

d) Book List
Course Test IX

32 What is the difference between a List form and a Tabular form?

a) A tabular form displays only one record.

b) A List form displays only one record.

c) A tabular form is not editable.

d) A List form is not editable.

33 What is the difference between a Worksheet form and a Tabular form?

a) A tabular form displays only one record.

b) A worksheet form displays only one record.

c) A tabular uses AutoSplitKey.

d) A worksheet uses AutoSplitKey.

34 What Function key is used to Post records?

a) F5

b) F9

c) F11

d) Shift+F5

35 What Function key is used to open the Card form from a List form?

a) F5

b) F9

c) F11

d) Shift+F5
X Course Test

36 What Function key is used to open the Statistics form from a Card
form?

a) F5

b) F9

c) F11

d) Shift+F5

37 In a report description, you design data items and what?

a) Sections.

b) The Request Form.

c) Only data items.

d) Both a and b.

38 Which of these is not a data item property in a report?

a) PrintOnlyIfDetail

b) AutoUpdate

c) ReqFilterFields

d) CalcFields

39 A section in a report is most like what?

a) A data item

b) A control

c) A form
Course Test XI

d) A codeunit

40 Which of the following can you do with data items in a report?

a) Indent them.

b) Link them.

c) Change the order of them.

d) All of the above.

41 What property is used to tell the report to group on fields?

a) TotalFields

b) GroupTotalFields

c) GroupFields

d) None of the above.

42 What property is used to tell the report to total on fields?

a) TotalFields

b) GroupTotalFields

c) GroupFields

d) None of the above.

43 To ensure that a tab for a data item is not shown on the request form
you must…

a) Clear the TotalFields property.

b) Simply set the ShowTab property to No.


XII Course Test

c) The tab will always show on the request form.

d) Set the DataItemTableView property to sort the data item.

44 True or False. If the Options tab appears on the request form, it is


always the last tab.

a) True

b) False

45 Which of the following is not a type of Report?

a) Financial report

b) Transaction report

c) Document report

d) Posting report

46 Which of the following can you do with data items in a dataport?

a) Indent them.

b) Link them.

c) Change the order of them.

d) All of the above.

47 Dataport fields describe what?

a) The layout of the table.

b) The layout of the report.

c) The layout of the form.


Course Test XIII

d) The layout of the file.

48 If AutoSave is set to No, what property must you set to get the
dataport to update existing records?

a) AutoInsert

b) AutoModify

c) AutoUpdate

d) If AutoSave is set to No, the dataport will not save any records
automatically.

49 Which of the following triggers are available in a codeunit?

a) onRun

b) onInsert

c) onAfterGetRecord

d) All of the above

50 True or False. You can assign the instance of a codeunit variable to


another codeunit variable.

a) True

b) False
XV Course Test Answers

Appendix B.

Course Test Answers

This appendix contains the answers to the questions in Appendix A.

ANSWERS
1 Which of the following are not objects that you can create in C/SIDE?

a) Tables

b) Forms

c) Reports

d) Code Groups

2 True or False. C/SIDE is an object oriented programming


environment.

a) True

b) False

3 A Table description is made up of Fields and what?

a) Indexes

b) Table Relations

c) Dataports

d) Keys
Course Test Answers III

4 Which of the following properties would not be available for a normal


code field?

a) CharAllowed

b) Length

c) Calcformula

d) Data Type

5 Which property would you use to keep a user from pasting records
into a table?

a) AllowCutPaste

b) PastIsValid

c) UserPaste

d) A user cannot paste records into a table from the clipboard.

6 Which property would you set to keep a field from being edited by the
user?

a) Editable

b) Enabled

c) AllowUserEdit

d) AllowModify

7 When you run a table from the Object Designer, what is displayed?

a) Raw data from the table.

b) The table object.

c) The fields and keys in a table.


IV Course Test Answers

d) A form that displays the data in the table.

8 The primary key in a table is used for what?

a) Sorting

b) Keeping each record unique.

c) Defining the default lookup form for the table.

d) Both a and b.

9 A secondary key in a table is used for what?

a) Sorting

b) Possibly, keeping each record unique.

c) Defining the default lookup form for the table.

d) Both a and b.

10 True or False. The user can only use the primary key on forms.

a) True

b) False

11 Relating two tables in a “one to many” relationship requires…

a) Changing both tables to point to the other.

b) Relating a field in the “many” table to a field in the “one” table.

c) Changing the table properties of the “many” table.

d) Both b and c.
Course Test Answers V

12 True or False. A conditional table relation can relate its table to more
than one other table.

a) True

b) False

13 What happens when you change the primary key of a record that has
other records in other tables related to it?

a) The values in the other tables change as well.

b) Those other records are orphaned.

c) The other records are deleted.

d) An error occurs.

14 What is required for a Sum FlowField to calculate properly?

a) Data in both tables being summed.

b) A ReqFilterField.

c) A SumIndexField.

d) A FlowFilter.

15 What is required for an Exist FlowField to calculate properly?

a) A SumIndexField.

b) A FlowFilter.

c) A boolean data type to put the value of the CalcFormula in.

d) Nothing.
VI Course Test Answers

16 What makes FlowFields and FlowFilters unlike all other fields?

a) They are decimal.

b) They always have a SumIndexField.

c) The data type is FlowField.

d) They are not stored in the table.

17 What would you name a master table that holds Book Information?

a) Book

b) Books

c) Book Info

d) tblBook

18 What would you name a subsidiary table that holds Address


information for customers?

a) Address

b) Addresses

c) Customer Address

d) Customer Addresses

19 A document is represented by what kinds of tables?

a) A Header table.

b) A Lines table.

c) A Header and a Lines table.

d) Document and Document History tables.


Course Test Answers VII

20 What is the name of the primary key field(s) of a Ledger table?

a) Entry No.

b) Customer No., Entry No.

c) Line No.

d) Customer No., Line No.

21 What property of a form binds it to a table?

a) TableNo

b) TableID

c) SourceTable

d) BoundTable

22 True or False. It is better to start all forms with the form wizard.

a) True

b) False

23 What is the property that you must set on a data control?

a) Lookup

b) SourceExpr

c) Drilldown

d) DataField
VIII Course Test Answers

24 Card forms…

a) Display one record from a table.

b) Have tabs across the top.

c) Are used for editing records.

d) All of the above.

25 Tabular forms…

a) Display many records from a table.

b) Have tabs across the top.

c) Are always non-editable.

d) All of the above.

26 A tablebox can usually be found on a

a) Tab of a Card form.

b) The center of a Card form.

c) Tab of a Tabular form.

d) The center of a Tabular form.

27 True or False. Option fields can be displayed using a Textbox or


Option buttons.

a) True

b) False
Course Test Answers IX

28 What type of button would you usually add to the bottom of a card
form?

a) Command Button

b) Menu Button

c) Option Button

d) You don’t, the wizard adds all the buttons for you.

29 What can you use to easily add fields to a form?

a) Field Menu

b) C/AL Editor

c) Menu Designer

d) Symbol Menu

30 What control allows you to display one form within another form?

a) Tablebox

b) Textbox

c) Matrixbox

d) SubForm

31 What name would you use for a Tabular form that displays information
from the Book table?

a) Book

b) Books

c) Book Card

d) Book List
X Course Test Answers

32 What is the difference between a List form and a Tabular form?

a) A tabular form displays only one record.

b) A List form displays only one record.

c) A tabular form is not editable.

d) A List form is not editable.

33 What is the difference between a Worksheet form and a Tabular form?

a) A tabular form displays only one record.

b) A worksheet form displays only one record.

c) A tabular uses AutoSplitKey.

d) A worksheet uses AutoSplitKey.

34 What Function key is used to Post records?

a) F5

b) F9

c) F11

d) Shift+F5

35 What Function key is used to open the Card form from a List form?

a) F5

b) F9

c) F11

d) Shift+F5
Course Test Answers XI

36 What Function key is used to open the Statistics form from a Card
form?

a) F5

b) F9

c) F11

d) Shift+F5

37 In a report description, you design data items and what?

a) Sections

b) The Request Form

c) Only data items

d) Both a and b

38 Which of these is not a data item property in a report?

a) PrintOnlyIfDetail

b) AutoUpdate

c) ReqFilterFields

d) CalcFields

39 A section in a report is most like what?

a) A data item

b) A control

c) A form
XII Course Test Answers

d) A codeunit

40 Which of the following can you do with data items in a report?

a) Indent them

b) Link them

c) Change the order of them

d) All of the above

41 What property is used to tell the report to group on fields?

a) TotalFields

b) GroupTotalFields

c) GroupFields

d) None of the above

42 What property is used to tell the report to total on fields?

a) TotalFields

b) GroupTotalFields

c) GroupFields

d) None of the above

43 To cause a tab for a data item not to show on the request form you
must…

a) Clear the TotalFields property

b) Simply set the ShowTab property to No


Course Test Answers XIII

c) The tab will always show on the request form.

d) Set the DataItemTableView property to sort the data item

44 True or False. If the Options tab appears on the request form, it is


always the last tab.

a) True

b) False

45 Which of the following is not a type of Report?

a) Financial report

b) Transaction report

c) Document report

d) Posting report

46 Which of the following can you do with data items in a dataport?

a) Indent them

b) Link them

c) Change the order of them

d) All of the above

47 Dataport fields describe what?

a) The layout of the table.

b) The layout of the report.

c) The layout of the form.


XIV Course Test Answers

d) The layout of the file.

48 If AutoSave is set to No, what property must you set to get the
dataport to update existing records?

a) AutoInsert

b) AutoModify

c) AutoUpdate

d) If AutoSave is set to No, the dataport will not save any records
automatically.

49 Which of the following triggers are available in a codeunit?

a) onRun

b) onInsert

c) onAfterGetRecord

d) All of the above

50 True or False. You can assign one codeunit variable the instance of
another codeunit variable.

a) True

b) False

You might also like