AddressFormatter class to help you work with the complexities of address formats. It provides the following functions to format addresses:
- FormatContact
- FormatPerson
- FormatQuote
FormattedAddress data structure is very straightforward. Simply loop over the FormattedAddress lines and print out each IFormattedField from FormattedFields.
The following code example demonstrates using AddressFormatter to get a formatted representation of a contact’s address, then loops over each line and prints out each address field.
ContactRow. Because it only contains properties from the contact table, it does not contain an Address property. To get a FormattedAddress from a ContactRow, the AddressFormatter expects an AddressRow as well.
FormatContact method converts the postal and street address to the format of the country that the contact belongs to. The example uses the AddressRow.GetFromIdxOwnerIdAtypeIdx method to get the desired contact address type.
Pre-defined address field names for person and contact:
Writing address information back to this data structure is not useful. There is no way to persist changes to a FormattedAddress back to the database. Therefore, when writing code inside NetServer core use the Contact and Person entity types to persist address changes. Both entity types expose an
Address property with relevant properties for dealing with respective address formats.