The posting process

Our journal is now ready to be posted. We've implemented all business logic, except the posting code.

The posting process

The posting process of a journal in Microsoft Dynamics NAV has several codeunits for the structure:

Let's have a look at the check line codeunit. When it comes to testing, Microsoft Dynamics NAV has a simple rule:

Test near, Test far, Do it, Clean up

First, we need to test the field in the journal line table, then read external data tables to check if all is good, and then post the lines and delete the data from the journal table.

It does not make sense to read the G/L setup table from the database if the document no. in our own table is blank, or to start the posting process and error out because the posting date is outside of a valid range. This would cause a lot of unnecessary I/O from the database to the client.

In the preceding code, we can clearly see that fields in our table are checked first, and then the date validation, and lastly the dimension checking.

The actual posting code turns out to be quite simple. The values are checked and then a register is created or updated.

All the fields are simply moved to the ledger entry table. This is what makes Microsoft Dynamics NAV simple and powerful.

Here, we can clearly see how easy it is to add a field to a posting process. Just add the fields to the journal line, the ledger entry, and add one line of code to the posting process.