Working with Default Company Addresses

1 minute read time.

If you need to list company default/main addresses you can link from the Company to the Address table. You don't need to link to the address_link table. The address link table is used to keep details about the alternative addresses that might be stored against a company, e.g. billing and delivery addresses.

"Working with a Person's Address Type" is an article that discusses how the address_link table is used. Although this article is discusses addresses linked to a person the principle is the same for company addresses of different types.

Each company can only have one default address as the foreign key field comp_primaryaddressid can only hold one value.

The addr_addressid field is the primary key of the address table and must be unique. There should be no duplicate values.

A direct join from the company to the address table on the addressid field will return the same number of rows as there are companies in the database.

e.g.


SELECT     dbo.Company.Comp_CompanyId, dbo.Company.Comp_Name, dbo.Company.Comp_Type, dbo.Address.Addr_City, dbo.Address.Addr_State, dbo.Address.Addr_Country
FROM         dbo.Company INNER JOIN
dbo.Address ON dbo.Company.Comp_PrimaryAddressId = dbo.Address.Addr_AddressId

will return 1203 rows from the default demo data because there are 1203 companies each with a default address.

Examples of views that use the default company address are

  • vQuoteOpportunity
  • vSearchListCompany
  • vSummaryCompany
  • vNotificationCompany
  • vMailMergeCompany
  • vMailMergeCase
  • vMailMergeOpportunity
  • vMailMergeSolution
  • vReportCompany
  • vEntityCompany
  • vSearchListOrders
  • vSearchListQuotes
  • vTargetListCompany

These can be used as templates for any custom view you need to create.

There are a number of articles that discuss working with addresses using the APIs