Now that we have Master Data, we can start recording transactions that are linked to the master data. We will implement this using an Example Journal and Example Entries. The Entries will be linked to both the Example Person and the Example Product table.
When creating a Journal we need a set of Tables, Pages, Codeunits and Reports. There are quite a few Journals in Microsoft Dynamics NAV with different levels of complexity, but they all have the same basic structure.
Creating a brand new Journal is not easily documented step-by-step, and would cost a considerable page count in this book. For most architects, creating a new journal is not a frequent task. Even in the standard Dynamics NAV application, new journals are added only in every few big releases.
When creating a new Journal in Dynamics NAV there is a trick that you can use, but it requires basic knowledge of the syntax that is used for external object text files.
In Microsoft Dynamics NAV the Resource Journal & Entry structure is very isolated and close to the Pattern definition that we use. We can mark the following objects in the object designer as illustrated in the next screenshot, and export them as a text file:
Using any text editor, we can then use the Find and Replace to create our own journal and entry using the following steps:
Resource
and Res
names. In our Journal we will use Example
and Ex
.ResJnlManagement
Codeunit:After importing your text file you can fine-tune your journal. In our example journal we have removed the recurring option to simplify the process.
The Resource Journal also uses the Test Report-Print Codeunit 228
. This Codeunit needs to be modified to support the Example Journal.
Although many Journal Line tables in Dynamics NAV contain C/AL
code in the OnValidate
triggers of the table, this code is only intended to be used when the table is used from the user interface as a journal.
An example of OnValidate
code in the General Journal Line is displayed in the following screenshot:
Journals are also used during the posting of Documents and other processes in NAV. During these processes the Journal Line table acts as an Argument table as illustrated in the following screenshot of Codeunit
Sales-Post (80):
During these processes, the data is already validated during the entering of the Document and tested in the Test Near and Test Far parts of the posting routine.