How do default addresses and persons get created for a Company?

When you create a new company using the standard system behaviour the Address and Person contact details that you provide get recorded into their separate tables and foreign key references are recorded on the company table to indicate which address and which person are default for that company.

The foreign key fields that are relevant are:

comp_primarypersonid
comp_primaryaddressid

In the Person table there are similar fields to link the person with the company and the persons default address.

pers_companyid
pers_primaryaddressid

If we consider the relationship between a address and a company we know that there should be a default address for the company. The default address for the company is always shown in the "Address" area on the CompanySummary page.

We can change the default address by navigating to the edit screen of the Address we wish to set as the new default for the company and ticking the "set as default" field.

The default address is used not just in the display but for mail merge and summary reports.

The "set as default" field is not created from a field in the database. It is generated from the dll and it controls the value that is stored in the comp_addressid field. If the check box is ticked then the current addressid is written into the company table. The field created in the HTML of the screen is called "DefaultAddress" and its value can be read in TableLevel scripts and Validation scripts using the FormValues() collection

e.g.

FormValues("DefaultAddress").

The actual caption is controlled in the interface by the translation

Caption Code: SetAsDefaultCompany
Caption Family: GenCaptions
Caption Family Type: Tags
Capt_US: Set as default address for Company

The check box can not be removed from the interface but the addressboxlong screen block that is used to generate the screen will allow clientside code to be placed in the custom_content field. Therefore this could provide you with a means of deciding when the check box is displayed.

Note:

The roles that people play with a company are stored in the person_link table. You can see these roles if you look at the person list that is called from the company screen. If you edit a person that is linked to a company the Types on contact are:

Admin
Finance
Operations
Sales
Support

The address list has similar behaviour. In the default system loaded with demo data the Types are

Business
Billing
Shipping

The table that links persons with address and companies with addresses is the address_link table.
Anonymous