Person Type and Address Type in Web Services

3 minute read time.
Below is some example C# code showing how a new Company record can be inserted into CRM using the Web Services API.

The code will result in a new Company with a default contact and default address with a phone number.

ewarebase[] CRMBase = new ewarebase[1];

company newCompany = new company();
crmid newRecordID = new crmid(); = "Panoply Technologies Plc";
newCompany.people= new ewarebaselist();
newCompany.people.records=new ewarebase[1];

newCompany.address = new ewarebaselist();
newCompany.address.records = new ewarebase[1];
newCompany.address.entityname = "address"; = new ewarebaselist(); = new ewarebase[1]; = "phone";

person newPerson = new person();

address newAddress = new address();
newAddress.address1 = "1 City Road"; = "London";
newAddress.postcode = "EC1 1AA";
newCompany.address.records[0] = newAddress;

phone newPhone = new phone();
newPhone.type = "Business";
newPhone.countrycode = "44";
newPhone.areacode = "20";
newPhone.number = "77701076";[0] = newPhone;

CRMBase[0] = newCompany;
addresult CRMAddResult = CRM60.add("company", CRMBase);

The phone number information can be marked as being of a particular type. In the code above I have marked this as being of type 'Business'. Additional phone numbers can be given the type 'Fax' etc.

The addition of email addresses for a new company is carried out the same way as adding a phone number. Each email address and phone number can be given a type.

The type is important as there is denormalisation behaviour that is invoked when adding a Company (and Person) record.

Phone numbers of type 'Business' and 'Fax' are copied into fields in the company table. Similar behaviour is invoked for Email addresses and for the Person and Phone/Email Tables.

The behaviour is very different for the address and person tables.

It is possible to add multiple address and contacts for a new company entity that is being inserted using the Web Service interface. The first person and address records added becomes the default address and contact for the company with their values entered into the comp_primarypersonid and comp_primaryaddressid fields.

Within the main user interface it is possible to provide a 'type' for each address and person that is associated with a company. So an address may be of type 'Billing' or 'Shipping' and a Person maybe of type 'Admin' or 'Sales'.

But there is no address type or person type field in the default web service interface as we have for the phone and email tables.

The reason partly lies in the data model.

The roles that people play within 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 table that links persons with address and companies with addresses is the address_link table.

In the default system loaded with demo data the Types are
  • Business
  • Billing
  • Shipping
For each role that a person play within a company there will be a record in the person_link table. For each type of address for a company there will be a record in the address_link table.

By default the link tables (Address_Link and Person_Link) are not exposed within the Web Service interface.

If you need to control address type and contact type then you will need to expose the person_link and address_link table to Web Services.

This can be done by updating the information in the custom_tables meta data table.

To expose the person link table use the following SQL
update custom_tables
set bord_webservicetable = 'Y'
where bord_name='person_link'
You will then need to refresh the meta data to ensure that the WSDL is updated.

The web reference in your Web Service application will also need to be updated to ensure that the new person_link object is available.