Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Learning Dynamics NAV Patterns
Learning Dynamics NAV Patterns

Learning Dynamics NAV Patterns: Create solutions that are easy to maintain, are quick to upgrade, and follow proven concepts and design

Arrow left icon
Profile Icon Mark Brummel Profile Icon Marije Brummel
Arrow right icon
$9.99 $30.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (5 Ratings)
eBook Sep 2015 214 pages 1st Edition
eBook
$9.99 $30.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Mark Brummel Profile Icon Marije Brummel
Arrow right icon
$9.99 $30.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (5 Ratings)
eBook Sep 2015 214 pages 1st Edition
eBook
$9.99 $30.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $30.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning Dynamics NAV Patterns

Architectural Patterns

Architectural Patterns are the larger building blocks of your application. They define how the data is stored in the database.

Microsoft Dynamics NAV uses the SQL Server as a database platform. Within the SQL Server, there are a large number of ways to store data. This chapter will discuss a number of ways that are best practice, which will be recognized by the experienced developers.

The members of the Architectural Patterns are the Design Patterns that typically contain field elements and pieces of business logic. Other parts of the business logic are provided by the internal API's generic containers with reusable functions.

All the patterns are described with an abstract, technical description, and with a few examples of the functional usages in the Microsoft Dynamics NAV application.

In this chapter, we will cover:

  • Singleton
  • Supplemental & Subsidiary
  • Compound
  • Rules
  • Master Data
  • Journal Template-Batch-Line
  • ...

The Singleton Pattern

Within the EARP application, we need to store information that is shared across the system for all the users. These values are unique in the application, and when changed they are valid immediately for everyone inside a company. They can be held in memory, and are only acquired from the database when changed. For this requirement, we can implement the Singleton Pattern.

Technical description

The Singleton pattern contains a table object with a specific primary key structure that is enforced by the system, allowing the table object to contain only one record. Users cannot add or remove records. When a new company is created, a record in each Singleton table is created automatically, although this is optional.

To enforce the existence of a record when it is required, each Page object that is based on the table should contain business logic to create the record, in case it does not exist yet. The reasons for the record to be missing can be that the table...

The Supplemental and Subsidiary Pattern

For Microsoft Dynamics NAV to run properly, we also require tables that contain more records to allow multiple values to be used in various scenarios. These values are almost as static as the Singleton tables, although the new records can be created during the lifecycle of the application.

The pattern for these tables is Supplemental & Subsidiary.

Technical description

The Supplemental & Subsidiary table has a single field Primary Key that is typically called Code; it has the Data type code, and has a length of 10 characters. Values in the Primary Key are manually determined by the application administrators. Normal users of the system have read-only access to these tables.

When the attributes in the table relate to another entity, the reference to this entity can be added as a second primary key.

The referenced entity is typically of the Master Data pattern. We will discuss Master Data later in this chapter.

The other...

The Compound Pattern

A Compound pattern helps us to define attributes that depend on a combination of two entities. This allows us to create additional flexibility when designing the application setup, creating values that connect through a many-to-many relationship.

Technical description

When applying this pattern, the table has two fields of type code and a length of 10 characters. Both the values should allow blank values.

The following diagram explains how to implement the Compound pattern:

To use the compound table in the application, both the fields are members of the table that uses the attributes. Typically, the compound key values are inherited from the fields in Master Data.

Implementation

The Compound table is used to define attributes for a combination of two values in the system.

Examples

The pattern is used in Microsoft Dynamics NAV for the General and VAT/TAX Posting Setup, which is as follows:

...

The Rules Pattern

The Microsoft Dynamics NAV EARP application is designed to work for small, medium-sized, and larger businesses. The Rules Pattern enables us to store information in the database with a sliding level of complexity.

Technical description

These tables have a composite Primary Key that has up to 20 fields, limited by the SQL Server or 900 bytes. The value being used in the application is based on rules. These rules are programmed in Codeunits.

The non-Primary Key fields typically determine the values that are being used after applying the rule, although these fields can also be a part of the Primary Key. For example, the selected printer, after filtering on the criteria, is an additional field in the table.

The following diagram explains how to implement the Rules pattern:

Implementations

The Rules Pattern is used for the setup tables, and for either pricing or discount information. It is also used to implement a Select Distinct...

The Master Data Pattern

The EARP systems are designed to deal with people and things. These people can be customers, vendors, or employees. The things can be the G/L Accounts, Items, Fixed Assets, or Loaners.

We will refer to people as the Person Master Data, and to Things as the Product Master Data.

Technical description

The Master Data tables have a single Primary Key of the Code length as 20. This code field is typically and automatically determined using the Number Series Pattern, although this is optional. To have a more humanly readable way to find records in the table, each Master Data has two text-fields of length 50, and a code-field of length 50.

The Number Series Pattern will be discussed in Chapter 3, Design Patterns.

The following diagram explains how to implement the Master Data Pattern:

For the People Master Data, these text fields are called Name and Name 2. The code fields is named Search Name. The Product Master Data has text...

The Journal Template-Batch-Line Pattern

In the Financial systems, Journals are used for accounting. Microsoft Dynamics NAV has an Architectural Pattern called Journal Template-Batch-Line that ensures data integrity, and acts as a datacontract for each transaction.

Technical description

Journals are the datacontracts, employed to create entries that are used for the accounting purposes. They can be used either manually via the user interface, or automated via processes, such as documents or batch programs.

Each Journal has a Journal Line table that has a Journal Template Code, and a Journal Batch Code. The Template can be used to influence the functional user interface, and the reports are being used in the process. The Batch allows different users to use the Journal at the same time without interfering with each other, or temporarily keep data in a Journal until it is ready to be posted.

The following diagram explains how to implement the Journal Template-Batch-Line Pattern...

The Entry Pattern

Most EARP systems are data cemeteries. A lot of data comes in, nothing much ever comes out. To store data in Microsoft Dynamics NAV, the Entry Pattern is most popular with over 75 implementations in the standard product.

Technical description

Although there are many variations, all entry tables have the same technical structure that can be expanded upon the functional requirements.

The Primary Key for all the entry tables is a field called Entry No. of the type Integer. The value of the field is determined using either the AutoIncrement property, or a code algorithm as the following:

IF NextEntryNo = 0 THEN BEGIN
  ExLedgEntry.LOCKTABLE;
  IF ExLedgEntry.FINDLAST THEN
    NextEntryNo := ExLedgEntry."Entry No.";
    NextEntryNo := NextEntryNo + 1;
  END;
WITH ExLedgEntry DO
  "Entry No." := NextEntryNo;

The following diagram explains how to implement the Entry Pattern:

Entry tables contain...

Document Pattern

The EARP systems are traditionally designed to help companies administer the paper trail, required to run their businesses, often from a legal perspective. To be able to register the paper documents in an electronic form, Document Pattern can be used.

Technical description

The Document pattern allows us to enter a header and line information. The header information is often related to Person Master Data (with whom I am doing business), whereas the lines are of the type Product (the kind of business that I am doing).

Each Document Pattern has two tables: a header and line. These names are important, the Sales Header and the Sales Line tables follow this convention, just as others.

The Header table

The header table has a primary key that is called No., and has a type Code with a length of 20 characters. Optionally, the primary key can also contain a reference to a normalized document type. Normalized in this case means that the share tables and business...

The Argument table

The Argument table has an ambiguous place in the categorization of patterns. The table is used to combine fields when we call a function. This can be compared to a class in object-oriented programming. Since Microsoft Dynamics NAV does not allow us to create a class, we use the table object instead. This will automatically create a table in the SQL Server, but this table will never contain any data. However, some tables are used for both arguments and normal data.

In computer programming, the general rule of thumb is to avoid functions that have too many arguments in the signature. When a function has more than three or four arguments, we should combine them into an argument table.

Technical description

The definition of the table should contain all the fields used in the arguments. The primary key of the table is not important, since the table will never contain actual data. However, the metadata in Microsoft Dynamics NAV requires at least one field as...

Summary

In this chapter, we have learned what Architectural Patterns are, and how to implement them in Microsoft Dynamics NAV. We have covered nine patterns that cover more than 95 percent of the tables that are defined with the standard application.

Using Architectural Patterns helps us to define tables when building our applications that others will recognize. This creates a common syntax within the community, and reduces the learning curve when bringing in new developers and architects.

In the next chapter, we will implement Design Patterns that will add elements to Architectural Patterns that define the usability of the application.

Left arrow icon Right arrow icon

Key benefits

  • Design software that is maintainable outside the ecosystem of their creators
  • Ensure quality by following patterns that have been proved to work
  • Over two dozen practical Architectural and Design patterns

Description

Microsoft Dynamics NAV is a complete ERP system, which also contains a robust set of development tools to support customization and enhancement. These include an object designer for each of the seven application object types, a business application-oriented programming language with .NET interface capability, a compiler, a debugger, and programming testing language support. Learning Dynamics NAV Patterns will guide you through the NAV way of solving problems. This book will first introduce you to patterns and the software architecture of the NAV and then help you to build an example application. Then, it walks you through the details of architectural patterns, design patterns, and implementation patterns. This book will also talk about anti-patterns and handling legacy code. Finally, it teaches you to build solutions using patterns. Proven patterns and best practices will help you create better solutions that are easy to maintain in larger teams across several locations. It will guide you through combining abstract patterns using easy-to-understand examples and will help you decide which patterns to use in which scenarios.

Who is this book for?

Learning Dynamics NAV Patterns is intended for developers, architects, (technical) consultants, and application managers. You may have very little or no knowledge about NAV patterns, but you should be acquainted with programming.

What you will learn

  • Apply object-oriented practices to C/AL programming
  • Structure your application to avoid merge conflicts
  • Refactor legacy code and avoid anti-patterns
  • Design decision trees to decide when to use which patterns
  • Clone codes and their application in Dynamics NAV
  • Make your application extensible by creating predefined hooks and facades

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 24, 2015
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552566
Vendor :
Microsoft

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Sep 24, 2015
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781783552566
Vendor :
Microsoft

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 170.97
Programming Microsoft Dynamics??? NAV 2015
$65.99
Learning Dynamics NAV Patterns
$38.99
Microsoft Dynamics NAV 2015 Professional Reporting
$65.99
Total $ 170.97 Stars icon
Banner background image

Table of Contents

8 Chapters
Chapter 1: Introducing Dynamics NAV Patterns and Software Architecture Chevron down icon Chevron up icon
Chapter 2: Architectural Patterns Chevron down icon Chevron up icon
Chapter 3: Design Patterns Chevron down icon Chevron up icon
Chapter 4: Building an Example Application Using Patterns Chevron down icon Chevron up icon
Chapter 5: Coding Best Practices Chevron down icon Chevron up icon
Chapter 6: Anti-patterns and Handling Legacy Code Chevron down icon Chevron up icon
Chapter 7: Building Solutions Using Patterns Chevron down icon Chevron up icon
Thank you for buying Learning Dynamics NAV Patterns Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(5 Ratings)
5 star 80%
4 star 0%
3 star 20%
2 star 0%
1 star 0%
Daniel Rimmelzwaan Dec 17, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Much of what is in this book is stuff that every NAV professional should already know. Mark took the better part of the past 2-3 years to actually think about capturing the essence of the patterns that we find in NAV. By breaking down the building blocks of the application, you get a great sense of how it all works, and how to use that knowledge to extend the application.This book is on my short list of must reads for consultants, business analysts, designers, and developers; anyone who works in this field really. If you deal with NAV in any way, this book will help you understand.
Amazon Verified review Amazon
Alain Krikilion Nov 29, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have read a lot of NAV books of which I thought: this is a book every C/AL developer (and preferably everyone somehow involved in NAV development) should read.I've also had some NAV books on which I preferred I never had my hands (or eyes) laid on it.Is this a book in either of these categories?No, it isn't!It is a book that every C/AL developer (and preferably everyone somehow involved in NAV development) MUST read! …. Twice! … At least!This is really the holy bible of C/AL development!The book explains how you should develop to make it more readable, maintainable, upgradeable.I am not going into details, because you should not read ABOUT it, but read it!
Amazon Verified review Amazon
Amazon Customer Dec 03, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I think that this book is one of the most importat for nav Developers.It's very usefull for developing with a basic rule.This is really the holy bible of C/AL development!Read it!
Amazon Verified review Amazon
Dean B. Dec 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is an excellent resource for all IT staff involved in a NAV project. Mark Brummel is an advocate for standards and convention, and he describes his ideas very effectively and simply. In addition, this book highlights changes from previous versions of NAV, so this book is an invaluable resource on a project moving from an older version of NAV to a newer version.
Amazon Verified review Amazon
Rene Thöne Jul 01, 2020
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Was ich erwartet habe: Tipps und tricks zur Programmierung, z.B. FindSET/FindFirst/Findlast Pattern, also welche Abfrage in welchen Fällen, trickreiches kombinieren von IsEmpty zu IF Findfirst/IF Findset.Abfragemuster mit gepufferten und Speicherreduzierten TmpTables, Hinweise zu Cursorverlusten udn einsetzende Tablescans bei bestimmten fehlerhaften Zugriffsmustern, die man mit Standardpattern leicht in den Griff bekommt.Was ich bekommen habe: Eine Information über Header/Line Relations, Prüf- und Post-Codeunits, Setuptables und das man das Code-feld als OK leer lässt.... Na ja, das ist jetzt kein großer Wurf. Anderseits "mache" ich Navision auch schon seit 1993 und habe daher diese Muster bereits im Rückenmark. Vielleicht bin ich daher auch etwas enttäuscht.Was Anfänger bekommen: Einsteiger in Navision bauen selten ganze Applikationen (für die man diese Pattern braucht), sondern nehmen eher kleine Anpassungen vor oder erstellen Kundenspezifische Auswertungen. Dafür ist dieses Buch nicht hilfreich.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.