Professional Documents
Culture Documents
Nav Development
Nav Development
Nav Development
Client:
The client can connect directly to a standard database file without going through
the server.
The client is also responsible for executing all the business logic.
The client reads objects from the database and is also responsible for running the
objects and controlling their behavior.
Server:
Controls the number of users that can connect to the database at one time.
Controls access to the data through locking.
Keeps track of all the read and write transactions performed by every user.
Returns data to each client, as requests are made.
Performs all key-based filtering and calculates SumIndexFields.
Caches data that can be requested again.
1
Satya
© private Solutions.
Note: Microsoft SQL Server also does all of these things. One thing that the standard
server does that SQL Server does not, is keep track of different versions of the same
record.
2
Satya
© private Solutions.
Basic objects:
1. Table object
a. It is used to storing and retrieving data
b. Understanding tables is the key to using all of the other objects.
2. Form object
a. A form is used to display data to the user in a familiar and useful way.
b. Most forms allow the user to add records to a table, view and modify
records as well.
3. Report object
a. It is used for printout details using filters and sorting based on that he or
she choose.
4. Dataport object
a. Dataports allow you to export or import table data.
5. Codeunit object
a. It allows you, the developer, to organize and group the code that you write.
(This only object doesn’t anything with tables.)
C/SIDE FUNDAMENTALS
Each type of application object is created using a specific tool called a designer.
Title bar: Get information about the name and path of the current database.
Status bar: See basic status information about your system (such as the current date
and your user ID)
3
Satya
© private Solutions.
General C/SIDE Concepts
All the five objects are used in the some general concepts those are…..
Properties: Properties are used to control the appearance of data, specify default
values, specify colors and define relationships.
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. For speed up the
searching in defined ways. (Like… primary key)
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.
Request Form: A request form is a form that is used in a report. For user specify
filters and options for the report.
Data items: these are like datasource in ax. Data items are mostly used in reports (I
update this later.)
4
Satya
© private Solutions.
Tables
A C/SIDE table may be visualized as a two-dimensional matrix consisting of columns
and rows.
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
o Properties
o Triggers
Keys
o Properties
Table properties
CaptionML: Sets the string that is used to identify a control or other object in the user
interface. (Here ML means Multi language.)
Description: Optional
Lookup Form ID: Sets the ID of the form you want to use as a lookup.
Drill down Form ID: Sets the ID of the form to use as a drill-down.
Paste Is Valid: Sets whether inserting records into this table using the paste command
is enabled.
5
Satya
© private Solutions.
Linked Object: Use this property to link to SQL Server objects. Property Yes
LinkInTransaction become available.
Field properties
Some properties are same as table properties, I write only unknown properties.
Flow Field: It is just like displaying the values in the table. Flow Field always
non-editable. When Field Class set to Flow Field then calcFormula is activated.
Flow Filter: To filter the data in the parent table, and get only required data.
AutoFormat Type:
AutoFormat Expr:
Caption Class:
Char Allowed: Range of characters user can enter into the field. Ex, adxz. It allows
only following character’s a,b,c,d,x,y,z
SQL Data Type: Here uses SQL data types Varchar, Integer, variant, BigInteger.
Table Relation: If you need any relation b/w this field and another table field.
6
Satya
© private Solutions.
Extended Datatype: some additional datatypes like phone no, email, etc..,
Boolean
CalcFormula: No use for the Boolean datatype because calcFormula only for decimals.
Blank Numbers:
Sign Displacement:
Not Blank:
Integ er
Auto Increment: if set to Yes, then it increment the value for next record.
Decimal
Option
Date
Closing Dates:
BLOB
Sub Type:
7
Satya
© private Solutions.
Owner:
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 primary key is composed of up to 20 fields in a record.
Primary key
Secondary key
Table relations
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 Table Relation property must be in the
primary key of the table specified by the table ID in the property.
8
Satya
© private Solutions.
Simple Table with Table Relations
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.
SumIndexFields
FlowFields
FlowFields are not a permanent part of the table data. It is a virtual field.
The information in the FlowFields exists only at run time.
FlowFields are automatically initialized to 0 (zero). To update FlowFields, you
must use the C/AL function <Record>.CALCFIELDS.
9
Satya
© private Solutions.
Types of tables
Master table
A Master table contains information about the primary focus subject of its
functional area.
The name of this table is the name of one of the records in the table.
Primary key: The Primary Key of a Master table is a Code field of length 20,
named "No." or occasionally "Code".
Standard Fields: The description field of this table is a Text field of length 30,
named "Name" or "Description".
Associated forms
There are three or more forms that are used with a Master table.
Card form
List form
Statistical form
10
Satya
© private Solutions.
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.
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.
Associated form
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 is set as the LookupFormID property of the table since it is used not
only for edit but also for Lookups into this table.
Note: For remaining type of tables refer “Navision attain object” pdf Page No.75.
11
Satya
© private Solutions.
Forms
Forms are used for entering information into database tables and for retrieving
and displaying information from database tables.
Form Description
Form Properties
Triggers
Controls
o Properties
o Triggers
Controls
All information on a form is presented in controls. Controls are objects that can
display data from a database table field.
Bound 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.
Unbound controls: An unbound form is not related to a table.
Triggers
Certain predefined events that happen to a form or a control cause the system to
execute a user-definable C/AL function-- -the event triggers the function. The event and
the function are together called a trigger.
The form wizard can create two different types of forms – Card forms and Tabular
forms.
Card Forms
A card form is a form that displays one record at a time to the user.
12
Satya
© private Solutions.
Tabular Forms
A tabular form is a form that displays many records at a time to the user.
Using FieldMenu
The Field Menu can be used to add fields to any bound form, whether you used the
wizard to create the form or not.
Click the gray box beside the Balance field to select the field (it should be highlighted in
blue).
13
Satya
© private Solutions.
In the Menu Designer you have above options.
Note: A PushAction of <0> will cause the button to do nothing (except fire its
OnPush trigger).
Creating Subforms
To display two different source tables information in a single form, we use the
Subforms.
Header form No. and Line form Document No. is always equal.
In the Subforms Line No. automatically incremented for that, we must set
AutoSplitKey property to Yes.
In the Subforms Document No. and Line No. must be in visible.
14
Satya
© private Solutions.
Types of Forms
Card form
A Card form lets the user view and edits one record at a time in a table.
Card form always has tabs. 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.
Statistics Form
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.
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.
Ex. Customer Statistics
Tabular form
A Tabular form is a multi-record form that lets the user view multiple records
from a table and edit them.
Tabular forms are named with the plural of the name of the table with which they
are associated.
Ex. General Posting Setup.
List form
A List form is a multi-record form that lets the user view multiple records from a
table at once, but not edits them.
Also, the Primary Key, always an integer named "Entry No.", is displayed in the
right-most column rather than the left-most column.
Ex. Customer Ledger Entries
Worksheet Form
15
Satya
© private Solutions.
The Primary Key fields of the associated table do not display on the Worksheet
Form.
The name of the worksheet form will end with the word "Journal".
Header/Line Form
Setup Form
A Setup form is a one-record form that lets the user view and edits 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 is only one record, the Primary Key does not display anywhere on this
form.
Ex. General Ledger Setup
A Menu form is a non-bound form 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.
Ex. General Ledger Menu.
There are other forms that let users view and/or edit multiple records at the same
time. These include TrendScape forms and Matrix forms.
Ex. Items by Location Form.
16
Satya
© private Solutions.
Reports
Reports are used to print information from a database in a structured way.
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.
Report structure
Report Description
Properties
Triggers
Data Items
Properties
Triggers
Sections
o Properties
o Triggers
o Controls
Properties
Request Form
Properties
Triggers
Controls
o Properties
o Triggers
Data Items
17
Satya
© private Solutions.
Sections
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.
Example. Sort order or level of detail.
Report properties:
UseReqForm: If Yes show report O.W., It just take a screen shot.
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.
Each data item can have one or more sections. To view the section Designer,
select the View menu and then Sections.
Note: If the report has its Processing Only property set to Yes you cannot create
any sections.
To create sections press F3.
To delete sections, select and press F4.
Body: This section is printed once for every record that is processed by the Data
item.
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. It
display bottom every page.
18
Satya
© private Solutions.
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.
Note: If you specify Table view then only we get GroupFooter value.
Header: This section is printed first for a Data item. It is also have print it on every
page option.
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.
The request form is the form that is displayed to the user when they run the
report.
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.
Request form used to generate report, according to user requirement.
Sections Work
Indentation or Linking
19
Satya
© private Solutions.
PrintOnlyIfDetail: it prints data only, if any related records in child table against to
parent table.
ReqFilterHeading: It is for specify for the tab name. While run the report. Before
preview.
Totaling In a Report
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.
To use grouping we add section called footer, and specify the TotalFields and
Group TotalFields properties.
Types of Reports
List report
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.
The name is usually the name of the table followed by the word "List", or
sometimes followed by the word "Listing".
Ex. Customer Listing, Item List.
Test report
20
Satya
© private Solutions.
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".
Ex. General Journal – Test, 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.
Ex. G/L Register, Item Register, Payroll Register.
Transaction Reports
A Transaction report has two DataItems. Master table and Ledger table.
This report is used to view all transactions for a particular Master record.
Ex. Trial Balance Detail/Summary, Vendor Account Detail, Employee
Transaction Detail.
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 header and lines are
displayed.
Header
o Header information is printed as though filling out an invoice document.
o It is repeated at the top of each page.
Lines
o The lines for the invoice print out more like a normal report in rows and
columns.
21
Satya
© private Solutions.
o The lines correspond to the header on the same page, and lines from other
invoices do not display on the same page.
Ex. Sales Invoice, Customer Statement, Purchase Order.
22
Satya
© private Solutions.
Basic Codeunits
A codeunit is a container for C/AL code that you want to use in many application
objects. If some you want the same function in different applications, 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.
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.
Codeunit Assignment:
Codeunit limitations:
Data types
23
Satya
© private Solutions.
Display variable
MESSAGE('The value of %1 is %2','LoopNo',LoopNo);
Note: It is not a "statement terminator", but instead signals the arrival of a new
statement.
Run-Time Errors
LoopNo := 27.5;
YesOrNo := 1;
Type conversion is not possible because 1 0f the operators contains an invalid type.
Boolean := Integer
MAXSTRLEN Function
Maxstrlen(description);
Output: 50.
COPYSTR Function
24
Satya
© private Solutions.
Copystr(<string>,<starting position>,<No. of char copy>);
Output: satya
Set Constant
Ex. [2,4,6,8,10]
IN Operator
IN operator checks to see if the value of the term preceding it is included in that set.
Logical Expressions
NOT
OR
OR True False
26
Satya
© private Solutions.
False True False
AND
XOR
If Statement
Syntax: IF <Boolean expression> THEN <statement>
27
Satya
© private Solutions.
Syntax: IF <Boolean expression> THEN [BEGIN]
<Statement 1> {; <statement 2>}
[END] ELSE [BEGIN]
<Statement 1> {; <statement 2>}
[END];
Exit Statement
The EXIT statement is used to stop the execution of a trigger.
{The second syntax is a block of comments. If a start brace ( { ) is inserted in the code,
the compiler will ignore it and everything following it until the matching end brace ( } )
is found.}
Arrays
An array is still a variable. The only difference between calling a simple variable and a
complex one is adding the element index.
Ex. SaleAmount[5] := 0;
If you want to clear or reset the array use the CLEAR Function.
Syntax: CLEAR(<variable>)
Ex. CLEAR(SaleAmount);
ARRAYLEN Function
It gives the length of the array.
Ex. ARRAYLEN(SaleAmount);
A repetitive statement is a statement that allows you to execute one or more other
statements multiple times. A repetitive statement is often called a "loop", because when
the execution reaches the end of the repetitive statement, it loops back to the beginning
of the repetitive statement.
FOR…TO Statement
29
Satya
© private Solutions.
Syntax: FOR <control variable> := <start value> TO <end value> DO [BEGIN]
<statement1>{;<statement2>}
[END];
Ex. REPEAT
i := i + 1;
MESSAGE('%1',i);
UNTIL i = 5;
There are several differences between the REPEAT and WHILE statements:
First, there can be more than one statement between the REPEAT and the
UNTIL, even if no BEGIN and END is used.
30
Satya
© private Solutions.
Secondly, the Boolean expression is not evaluated until the end, after the
statements have already been executed once.
And third, when the Boolean expression is evaluated, it loops back to the
beginning if the expression evaluates to False and terminates the loop if the
expression evaluates to True.
For example you want to get the customer details then you get those details like..,
Customer.Name := Txt[1];
Customer.Address := Txt[2];
Customer.City := Txt[3];
Customer.Contact := Txt[4];
Customer."Phone No." := Txt[5];
Here every time we use “customer.” record variable name. So to reduce this we use
WITH statement.
31
Satya
© private Solutions.
3:MESSAGE('This is 3');
END;
Output: This is 2
Function
If we use random function, it gives random number b/w 1 and given maximum
number in random function.
Random function always gives same value as output for every execution.
If we use randomize function without parameters, before random function.
Then it gives different random number for every execution.
Ex. RANDOMIZE();
i := RANDOM(125);
MESSAGE('%1',i);
32
Satya
© private Solutions.
Advanced
Complex Data Type
Complex data types are those that have more than just a value and operators.
Complex data types, however, have properties or methods along with a value (or
values).
For instance, a form data type has a value (the form object), but it also has
methods like the RUN method that displays the form to the user.
It also has properties like LOOKUPMODE.
Complex datatypes are BLOB, CodeUnit, Dataport, Dialog, etc..,
All of these data types have one method in common, the RUN method.
By using the CODEUNIT.RUN function to create and run a codeunit, you dynamically
create an instance of a codeunit based on the ID.
Accessing CodeUnit
Example
CODEUNIT.RUN(393); //No record variable
CODEUNIT.RUN(393, Rec); //With record variable
33
Satya
© private Solutions.
Accessing Forms
Forms can be run in much the same way as Codeunits, with a form variable or
using the FORM.RUN function. However, you can also run them modally using the
RUNMODAL method instead of RUN.
As with forms, reports and dataports can be run with a variable, without a variable,
modally or non-modally.
Examples
ReportVariable.RUN;
REPORT.RUN(Report ID);
ReportVariable.RUNMODAL;
DataportVariable.RUN;
DATAPORT.RUN(Dataport ID);
DataportVariable.RUNMODAL;
Retrieving a Record
GET
This method uses the primary key values to find the matching record in the
database. Once the record is found, it fetch data from the database.
The GET method ignores the record set and goes directly to the table to retrieve
the record.
Ex. Customer.GET('50000'); //No. is the primary key field
Customer.GET(CustNo); //Using a variable
Customer.GET(Rec.”No.”); //Using a field from another Record Variable
FIND
34
Satya
© private Solutions.
It is used to go to a specific record in a record set.
Usually this function is just used to go to the first or the last record within a
record set, but you can use it for searching as well.
GET only retrieve the data for current filter.
Additionally, FIND can be instructed to look for records where the key value is
equal to, larger than or smaller than the search string.
o Find(‘+’) goes to the bottom of the table and sets the record variable to the
last record.
o Find(‘-’) goes to the top of the table and sets the record variable to the first
record.
o Find(‘=><’)
NEXT
Once you have retrieved a record from the database, you may want to retrieve the very
next record or a previous record. Then NEXT method will be useful.
INSERT
If you want to insert a record to the table through the code then we use insert
function. If you want to run the OnInsert trigger of the table during the insert, you must
pass TRUE into the function.
MODIFY
Example: EmpList.GET('RR');
EmpList.”FIRST NAME” := ‘Rakesh’;
EmpList.RENAME;
A set of records can be referred to by the term Record Set. A Record Set is defined
by the Key and Filters that the record variable has been assigned. This is sometimes
called a “View”. For this use the method functions SETCURRENTKEY, SETRANGE
or SETFILTER.
SETCURRENTKEY
The SETCURRENTKEY method assigns a new key to a record variable.
36
Satya
© private Solutions.
A run-time error occurs if the function cannot find a Key that contains all the
fields specified in the order specified.
Example: Customer.SETRANGE("No.",'10000','90000');
SETFILTER
Temporary tables
Temporary tables allow you to minimize the impact on the server in two main areas
Reducing the calls to the server and in allowing you to create records that may
not yet exist on the server.
o Depending on the requirement report may need to read from the table
many different times
o By reading the data once from the server and storing the data in a
temporary table we are able to minimize the impact on the server as well
as the amount of network traffic.
working with dimensions there may be times when you want to create data
o The processing is taking place on the client the impact on the server is
minimized.
37
Satya
© private Solutions.