Just as Number Series, implementing addresses is typical when working with ERP applications. Microsoft Dynamics NAV follows a number of steps when using the addresses.
Addresses in Microsoft Dynamics NAV are not fully normalized. Each implementation creates a new set of predefined fields in a table, and copies the values. This has some advantages such as simplicity and filtering. The downside is that addresses use a lot of space in the record sets.
This video, available at https://www.youtube.com/watch?v=60Wrx9N-gfY&list=PLhZ3P-LY7CqmVszuvtJLujFyHpsVN0U_w&index=19, explains the Address Integration Pattern.
Implementing addresses in Microsoft Dynamics NAV requires a set of fields to be implemented, values to be inherited, and the definition of a formatting function in the FormatAddress Codeunit.
When using Addresses in Microsoft Dynamics NAV, the following fields are typically implemented:
Field Name |
Type |
Length |
Comment |
---|---|---|---|
Name |
Text |
50 | |
Name 2 |
Text |
50 | |
Address |
Text |
50 | |
Address 2 |
Text |
50 | |
City |
Text |
30 |
Table Relation with table 225 Post Code |
Contact |
Text |
50 | |
Country/Region Code |
Code |
10 |
Table Relation with table 9 Country/Region |
Post Code |
Code |
20 |
Table Relation with table 225 Post Code |
County |
Text |
30 |
Caption is State in North America |
When more than one address is used in one table, the field names should be more specific; for example, Bill-to Name and Ship-to Name.
The fields called City and Post Code are related to the Post Code table. This relation is validated by the following C/AL code:
City - OnValidate() PostCode.ValidateCity(City,"Post Code",County,"Country/Region Code",(CurrFieldNo <> 0) AND GUIALLOWED); Post Code - OnValidate() PostCode.ValidatePostCode(City,"Post Code",County,"Country/Region Code",(CurrFieldNo <> 0) AND GUIALLOWED);
Addresses are related to the Master Data of the type Person that we discussed in Chapter 2, Architectural Patterns.
In Microsoft Dynamics NAV, the address information is synchronized between the Contact table and their related Customer, Vendor, and Bank Account records.
The synchronization is described in Chapter 2, Application Design, of the Microsoft Dynamics NAV 2013 book.
An explanation of how the Customer and Vendors are linked to a Contact is available at http://www.olofsimren.com/connect-a-customer-with-a-vendor/.
When addresses are used in Documents, the values are copied from Master Data or the source document. When the address changes at the source, the inherited values are not updated.
The following code snippet, taken from the Sales Header table, shows how the data is copied from one record to another:
Bill-to Customer No. - OnValidate () … GetCust("Bill-to Customer No."); … "Bill-to Customer Template Code" := ''; "Bill-to Name" := Cust.Name; "Bill-to Name 2" := Cust."Name 2"; "Bill-to Address" := Cust.Address; "Bill-to Address 2" := Cust."Address 2"; "Bill-to City" := Cust.City; "Bill-to Post Code" := Cust."Post Code"; "Bill-to County" := Cust.County; "Bill-to Country/Region Code" := Cust."Country/Region Code";
When creating history from documents, the values are typically forwarded using the TRANSFERFIELDS function. We will discuss that later in this chapter.
The primary reason for using addresses is to print them on documents and envelopes. When we do this, we need to make sure that the empty values don't use unnecessary space. Also, the formatting of addresses, especially the Post Code, is sometimes different per country. The Codeunit 365 FormatAddress takes care of all the formatting, and converts the field values into an Array of text values.
In the following screenshot, we can see that Address 2 does not leave a blank line when printing the address on a Contact Cover Sheet:
Each implementation of the Address fields has a unique function in this Codeunit. Out of the box, this Codeunit can format addresses from over 65 sources.
The signature of each function is always the Text Array and the source table:
Company(VAR AddrArray : ARRAY [8] OF Text[50];VAR CompanyInfo : Record "Company Information")
WITH CompanyInfo DO
FormatAddr(
AddrArray,Name,"Name 2",'',Address,"Address 2",
City,"Post Code",County,''),
When required, this Codeunit should be declared as well as the Text Array. The Text Array can then be used in the dataset of reports.
3.147.53.166