Showing posts with label OBJECTS IN NAV 2013. Show all posts
Showing posts with label OBJECTS IN NAV 2013. Show all posts

Tuesday, 4 February 2014

Is Microsoft Dynamics NAV Object Oriented ?

Microsoft Dynamics NAV is not object-oriented but object-based. This is an important distinction. In an object-oriented language or environment, developers can create new types of objects based on the ones that are already in the system.
In C/SIDE, developers have eight types of application objects and that is all.Developers can create and use Tables, Forms, Pages, Reports, Dataports,
XMLports, Codeunits, and MenuSuites, but nothing else.
Limiting developers to use these eight objects makes their work faster and more efficient. The biggest benefit from this limitation is stability. It is fairly difficult to create a severe bug in C/SIDE.

PAGE Object

Page and Action Triggers
Microsoft Dynamics NAV 2013

Page triggers allow you to use C/AL code to control the behavior of the system as a result of an event on the page, such as a page opening or a field changing its value. You typically use page triggers for advanced validation and logic.
Page triggers can be divided into three categories:
  • General page triggers that apply to the entire page
  • Field page triggers that apply to a field control on a page
  • Action triggers that apply to an action on a page.
General Triggers
The following table lists triggers that apply to the entire page.
Page trigger nameExecuted
OnInit TriggerWhen the page is   loaded, but before the controls are available.
OnOpenPage TriggerWhen the page is   initialized and the controls are available.
OnClosePage TriggerWhen the page about to   close and after OnQueryClosePage Trigger trigger.
OnFindRecord TriggerWhen the page is   opened and a record is retrieved from a table.
OnNextRecord TriggerWhen the page changes   from displaying one record to another record in a table. For example, on a   Customer card page, this happens when a user selects Next (Ctrl+Page   Down) or Previous (Ctrl+Page Up).
OnAfterGetRecord TriggerWhen a record has been   retrieved but not yet displayed.
OnNewRecord TriggerWhen a new record has   been initialized but not yet displayed.
OnInsertRecord TriggerWhen a new record is   about to be inserted in the table.
OnModifyRecord TriggerWhen a record is about   to be modified in the table.
OnDeleteRecord TriggerWhen a record is about   to be deleted from the table.
OnQueryClosePage TriggerWhen the page is about   to close, but before the OnClosePage Trigger
Field Triggers
The following table describes the triggers that are available on field controls.
Control triggerExecuted
OnValidate (Page fields) TriggerWhen the user changes   the value in a field and then selects away from the field so that the field   loses focus.
OnLookup (Page fields) TriggerWhen the user requests   a lookup by clicking a field’s lookup button or pressing F4.
OnDrillDown TriggerWhen the user requests   a drill-down by choosing the field’s drill-down button or pressing Shift+F8.
OnAssistEdit TriggerWhen the user requests   assist-edit by choosing an AssistEdit button or by pressing Shift+F4.
OnControlAddin TriggerWhen a control add-in   is initiated on a page.
Action Triggers
The following table lists triggers that apply to actions on a page.
TriggersExecuted
OnAction TriggerWhen an action is   initiated on a page.

REPORT object

Report Triggers
The following table lists triggers that apply to the report itself.
TriggerExecuted
OnInitReport TriggerWhen the report is   loaded.
OnPreReport TriggerBefore the report is   run, but after the RequestPage has been run.
OnPostReport TriggerAfter the report has   run, but not if the report was stopped manually or by the QUIT Function (Report, XMLport).
In Report we define the Data Items and its triggers are as follows
Data Item Triggers
The following table lists triggers that apply to each data item on the report.
The Trigger executing style for Report already i published in my blog .

TriggerExecuted
OnPreDataItem TriggerBefore the data item   is processed, but after the associated variable has been initialized.
OnAfterGetRecord (Data Items) TriggerWhen a record has been   retrieved from the table.
OnPostDataItem TriggerWhen the data item has   been iterated for the last time.

XML PORT Object

Microsoft Dynamics NAV 2013
From NAV 2013 we can run XML port direclty.
The following triggers apply to XMLports.
XMLport triggerExecuted
OnAfterAssignField TriggerExecuted after a field has been assigned a value and before it   is validated and imported.This   trigger is only used to import data.
OnAfterAssignVariable TriggerExecuted after the value defined in the XML document is assigned   to the text variable.This   trigger is only used to import data.
OnAfterGetField TriggerExecuted after a field is passed to the XML document.This   trigger is only used to export data.
OnAfterGetRecord (XMLports) TriggerExecuted after a record is retrieved from a table and before it   is exported to the XML document.This   trigger is only used to export data.
OnAfterInitRecord TriggerExecuted after a record is loaded.This   trigger is only used to import data.
OnAfterInsertRecord TriggerExecuted after a record has been inserted into a database table.This   trigger is only used to import data.
OnBeforeInsertRecord TriggerExecuted after a record has been loaded and before it is   inserted into a database table.This   trigger is only used to import data.
OnBeforePassField TriggerExecuted before a field is passed to the XML document.This   trigger is only used to export data.
OnBeforePassVariable TriggerExecuted after the source expression has been formatted into a   text variable and before the text variable is passed to the XML document.This   trigger is only used to export data.
OnInitXMLport TriggerExecutes   when the XMLport is loaded and before any table views and filters are set.
OnPreXMLport TriggerExecuted   after the table views and filters are set and before the XMLport is run.
OnPostXMLport TriggerExecutes   after the XMLport is run.
OnPreXMLItem TriggerExecuted after the table is initialized and before you start   exporting data to an XML object. This trigger only applies to XMLport   elements that have a source type of Table.This   trigger is only used to export data.

Query Object

Query Triggers
 It is new Object introduced from Microsoft Dynamics NAV 2013

This topic describes the C/AL triggers that are available for queries. Triggers are typically used to perform calculations and verification. Triggers allow you to control how data is selected and retrieved in a more complex and effective way than you can achieve by using properties.

Query Object Triggers

The following table lists the triggers that apply to the query object.
TriggerExecutes
OnBeforeOpenBefore the   query object is run and the dataset is generated. For example, you can use   the OnBEforeOpen trigger to apply filters using the SETFILTER function.

Code Units


Codeunits  Used to organize and group code which is written by the developers

Codeunit Triggers
Microsoft Dynamics NAV 2013

The following triggers apply to codeunits.

Codeunit trigger nameExecuted
OnBeforeTestRun TriggerBefore a   test function of a test codeunit is run.
OnAfterTestRun TriggerAfter a   test function of a test codeunit is run.

FORMS

Forms Used to display data to users in the Microsoft Dynamics NAV Classic client. Forms allow users to add records to a table, and to view and modify records.

[ This object is not using from earlier version  of  NAV 2013]


OnInit
OnOpenForm
OnCloseForm
OnQueryCloseForm
OnActiveteForm

Different TABLES in NAV


Microsoft Dynamics NAV has three types of tables that serve special purposes. The types of tables are:
·         Temporary 

·         System 

·         Virtual
Temporary tables are used as a repository for temporary information at run time. System and virtual tables are system generated tables that provide information about the current state of the system.


Temporary Tables

A temporary table is a temporary variable that holds a table. A temporary table is used as a buffer for table data in your C/AL programs. For more information about C/AL, see Introduction to C/AL.

You can use a temporary table just like you use a database table. The differences between a temporary table and a database table are as follows:

·         A temporary table is not stored in the database, but is only held in memory until the table is closed.

·         The write transaction principle that applies to a database table does not apply to a temporary table. For more information, see Write Transactions and Recovery.

Advantage of a Temporary Table

The advantage of using a temporary table is that all the interaction with a temporary table occurs on the client. This reduces the load on both the network and the server.

When you want to perform many operations on the data in a specific table in the database, you can load the data into a temporary table when you modify it. Loading the data into a temporary table speeds up the process because all the operations are performed locally on the client.

Defining and Using a Temporary Table


You must define the temporary table before you can use it in your C/AL code. The variable that holds a temporary table is defined just like any other global or local variable.

To define a temporary table


1.       On the Tools menu, choose Object Designer, and then create a new table.

For information about how to create a table, see How to: Create a Table.

2.       Choose View, and then choose C/AL Globals or C/AL Locals, depending on whether your variable will be global or local.

If you choose C/AL Globals, the C/AL Globals window appears

3.       Enter a name for the temporary table variable, and enter or select Record as the data type. Use the up arrow in the Subtype field to select the table to copy.

4.       With the cursor still on the line that defines the temporary table, choose View, and then choose Properties (Shift+F4) to display the Properties window.

5.       Change the value of the Temporary property to Yes.

After you have created a temporary table, you can use it in your C/AL code. You can apply filters and perform searches just as you can with a database table.


System Tables


System tables are stored in the database just like normal database tables. However, unlike normal database tables, they are created automatically. The information in system tables is closely related to the DBMS, which uses the system tables to manage, for example, system security and permissions in C/SIDE.

You can read, write, modify, and delete the information in system tables.

There are eight system tables in C/SIDE. The following six tables handle system security:

·         User System Table

·         User Role System Table

·         Permission System Table


The following two tables define data structure:

·         Company System Table



Virtual Tables


A virtual table contains system information. You cannot change the data in virtual tables. You can only read the information. Virtual tables are not stored in the database but are computed by Microsoft Dynamics NAV at run time.

Using Virtual Tables


You can use the same methods to access information in virtual tables as you use when you are working with ordinary tables. For example, you can use filters to get subsets or ranges of integers or dates from the Integer virtual table or the Date virtual table.

A system administrator usually uses these virtual tables. These tables give the system administrator information about the users who are currently connected to the database and the current state of the system.

The virtual tables provide such information as:

·         Integers in the range –1,000,000,000 to 1,000,000,000.

·         Dates in a given period.

·         Overview of the operating system files.

·         Overview of the logical disk drives.

·         Trace of database requests from your client to the database.

·         Overview of the users who are currently connected to the database.

·         Overview of the operating system files that store the database.

Because virtual tables are not stored in the database, you cannot view them directly. To view a virtual table, you must create a list page based on the virtual table. For more information, see How to: Create a Page to View a Virtual Table.

TABLE Object

Tables Used to describe how data is stored in the database and how it is retrieved. Understanding tables is the key to using all of the other objects in C/SIDE.
The triggers in a table can be divided into two categories:
·         Table triggers
·         Field triggers
Tables have the following triggers.


Table trigger

Executes when


A new record is inserted into the table.


A record in the table is modified.


A record in the table is deleted.


A record is modified in a primary key field.
Fields have the following triggers.


Field trigger

Executes when


Data is entered in a field or when the VALIDATE Function (Record) is executed.


Lookup is activated.

Special Table Fields

In addition to the conventional data fields which hold values, three kinds of
Specialized fields are available for data retrieval:
• SumIndexFields
• FlowFields
• FlowFilter Fields

1.FlowFields

A FlowField is a virtual field that extends the table data. It is not a permanent part of the table data.
A Flowfield is a powerful feature of the Microsoft Dynamics NAV database system. It is used to calculate values from another table. The information in the FlowFields exists only at run time. The values in FlowFields are automatically initialized to zero (0).
To update a FlowField, developers use the CALCFIELDS function that has the
following syntax:
<Record>.CALCFIELDS

If a FlowField is a direct source expression of a control on a form, the FlowField is automatically calculated when the form is displayed.

2.FlowFilter
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 is designed by using FlowFilter fields for the FlowFields.

3.SumIndexFields
A SumIndexField is a decimal field that can be attached to a key definition. This is the fundamental feature of the Microsoft Dynamics NAV database that constructs the basis for FlowFields. SumIndexFields enable fast calculation of numeric columns in tables, even in tables with thousands of records. This is because SumIndexFields are maintained when the database record is updated.
SumIndexFields enable the fast calculation such as sums of columns to be displayed by using FlowFields. For example, in a conventional database system, –à The Sales FlowField is not yet usable. For the system to calculate the Sales FlowField, a SumIndexField must be created in the Sales Transactions table with a correct key.