Dynamics NAV 2016 Design Patterns
Design Patterns is the standard solution, which can be repeated to solve the most common problems. It is generally a part of the full system design. It can be taken as a proven concept in the application.
There are three different types of Design Patterns, which are clearly distinct in Microsoft Dynamics NAV 2016.
Architectural Design Pattern
Microsoft Dynamics NAV is highly based on Architectural Design Patterns, where highly reusable components are implemented so as to provide a dynamic structure to the system. It can be considered as a Software Design pattern.
Implementation Pattern
In Microsoft Dynamics NAV 2016, we use several Implementation Patterns, which are nothing but different development techniques. Most common Implementation Patterns are done for program organization and data structures.
Design Pattern
Design Patterns are reusable patterns that can be used to solve a specific problem. In Dynamics NAV, we use number series, blocked entity, and so on.
In most cases, a developer faces a problem where he/she needs to replicate the pre-existing functionality or some part of a module. It is essential that the developers understand about the design patterns implemented so as to get the best results and a clear understanding.
Implementing the Activity Log Pattern
The idea behind an activity log is that, whenever something happens, we can write down what happens and when it happens. We will follow the steps listed next for implementation of the Activity Log Pattern:
- Record the activity
- One centralized view
- Present to the user
The Activity Log feature records the activity, its outcomes, and success. We will assemble everything in one centralized view, and then present everything using filters.
We will start with the use of Table 710 Activity Log, as shown in the following screenshot:
This is the part where the Activity Log Design Pattern captures the related detailed information on any kind of activity. The activity could be an error message, warning message, or just a confirmation message. There are three categories of log management:
- Log insertion
- Log modification
- Log deletion
The most common places where you can utilize these logs are Posted Sales Credit Memos and Posted Sales Invoices. You can click on the Activity Log button to view the activity in order to back trace what happened in the documents. The Activity Log feature always filters the view, which concludes our third step, Present to the user. This presents the proper message filter to the correct user. Filter also filters the Activity Log feature on the basis of date, and provides the exact log that the user is looking for:
Now we will examine how this pattern outputs data, and presents it to the user.
We will take the example of a Posted Sales Invoice page, which has an action called Activity Log. It links the page with the logic that is connected to the Activity Log sub-system which implements the design pattern.
Let's examine the Page action of Page 132: Posted Sales Invoice. Here, you can find an action called Activity Log. We can find the code written on the onAction() trigger of this action by pressing F9, or by clicking the C/AL Code button in the header, as shown in this screenshot:
It has a function called ShowActivityLog. This function takes RECORDID as an argument, and passes it to the ShowEntries function of the Activity Log table:
The function gets RecordID as an argument, filters the data as per the record and date, and presents the Activity Log to the user, as seen in this screenshot:
Setting up a change log
Open the Microsoft Dynamics NAV 2016 Role Tailored client, and perform the following steps:
- Go to Departments | Administration | IT Administration | General | Tasks | Change Log Setup.
- Click on the Action tab in Change Log Setup, and choose Tables.
The Change Log Setup (Table) List window will open.
- Select the table you want to include.
- Select Some Fields or All fields.
For the Some fields option, you need to define a list of fields that you want to select. Use the Assist Edit button to do so. Close the window.
- Finally, in the Change Log Setup window, select the Change Log Activated field:
Your setup is complete.
Viewing the Change Logs Entries page
We can view all the changes logged in RTC in the Change Log Entries page. To view the logs, just go to the page with the help of the following path:
Departments | Administration | IT Administration | General | Change Log Entries
This will show you a list of all the change logs. This is crucial from the administrative point of view: