-->![Microsoft Dynamics Nav 2009 Tutorial Microsoft Dynamics Nav 2009 Tutorial](https://stoneridgesoftware.com/wp-content/uploads/2016/07/Krisit-S_Tool.jpg)
![Microsoft dynamics nav 2009 upgrade toolkit manual Microsoft dynamics nav 2009 upgrade toolkit manual](http://costcontrolsoftware.com/wp-content/uploads/2011/01/Getting-Started-with-Report-Writer-300x300.png)
Sign In Popup
This section describes where to write C/AL code and how to reuse code.
Microsoft Dynamics NAV Training Materials Classic (v5.0 / 2009): What's New with NAV 5.0 Table of Contents Introduction Online Map Integration Export to Word.
For more information about how to use system-defined variables, see System-Defined Variables.
![Microsoft Dynamics Nav 2009 Tutorial Microsoft Dynamics Nav 2009 Tutorial](https://stoneridgesoftware.com/wp-content/uploads/2016/07/Krisit-S_Tool.jpg)
For more information about the most frequently used C/AL functions, see Essential C/AL Functions.
Where to Write C/AL Code
Almost every object in Dynamics NAV contains triggers where you can add your C/AL code. Triggers exist for the following objects:
- Tables
- Table fields
- Pages, including request pages
- Reports
- Data items
- XMLports
- QueriesYou can initiate the execution of your C/AL code from the following:
- Actions
- Menu items
- Any object that has an instantiation of the object that contains C/AL code. An example of an instantiation is a variable declaration.NoteIf the C/AL code is in a local function, then you cannot run it from another object.
Guidelines for Placing C/AL Code
We recommend the following guidelines for C/AL code:
- In general, put the code in codeunits instead of on the object on which it operates. This promotes a clean design and provides the ability to reuse code. It also helps enforce security. For example, typically users do not have direct access to tables that contain sensitive data, such as the General Ledger Entry table, nor do they have permission to modify objects. If you put the code that operates on the general ledger in a codeunit, give the codeunit access to the table, and give the user permission to execute the codeunit, then you will not compromise the security of the table and the user will be able to access the table.
- If you must put code on an object instead of in a codeunit, then put the code as close as possible to the object on which it operates. For example, put code that modifies records in the triggers of the table fields.
Reusing Code
Reusing code makes developing applications both faster and easier. More importantly, if you organize your C/AL code as suggested, your applications will be less prone to errors. By centralizing the code, you will not unintentionally create inconsistencies by performing the same calculation in many places, for example, in several triggers that have the same table field as their source expression. If you have to change the code, you could either forget about some of these triggers or make a mistake when you modify one of them.
See Also
System-Defined Variables
Essential C/AL Functions
Essential C/AL Functions
![Microsoft dynamics nav 2009 upgrade toolkit manual Microsoft dynamics nav 2009 upgrade toolkit manual](http://costcontrolsoftware.com/wp-content/uploads/2011/01/Getting-Started-with-Report-Writer-300x300.png)
WordCustomRefiner2#afd1ca55-403d-404c-b60c-692906bef937
WordCustomRefiner3#cb001ab7-1f19-4da1-8860-3e04d243802c
Download
Download What's New, Installation, Upgrade, and Developer Guides for Microsoft Dynamics NAV 2009 R2 here.
The content of this page is locked.
To access this information log in to CustomerSource.
Unable to log in to CustomerSource?
Visit our CustomerSource Help Page.
Close
The content of this page is locked.
To access this information log in to CustomerSource.
Unable to log in to CustomerSource?
Visit our CustomerSource Help Page.
Your current service plan does not allow access to this information.
To learn more about Microsoft Dynamics Service Plans review our
service plan offerings.
service plan offerings.