Step three – Journals & Entries

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.

Creating your own Journal and Entry

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:

Creating your own Journal and Entry

Using any text editor, we can then use the Find and Replace to create our own journal and entry using the following steps:

  1. Create a new object number structure for your add-on and replace the numbers. Remember to do this in an intelligent way, as the number you are replacing might be used for other purposes than object numbering:
    Creating your own Journal and Entry
  2. Find and Replace the object names with your names. The Resource Journal uses the Resource and Res names. In our Journal we will use Example and Ex.
  3. Change Table Relations to your tables.
  4. Replace the Text Constants in the ResJnlManagement Codeunit:
    Creating your own Journal and Entry

    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.

  5. After importing the text file and cleaning it up, we should have the following objects:
    Creating your own Journal and Entry

Validation in Journals

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:

Validation in Journals

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):

Validation in Journals

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset