Working with companies in API

Company card -screenshot

Companies are in code and database references called contact. Use the context to determine whether contact denotes a real-life company or person. Read more about the SuperOffice view of the world.

โš ๏ธ Warning
Changing the company table will make it impossible to sign in for all users. The only fix is to restore the database from backup.

Company vs. other entities

The company card uses the contact table and its related tables:

Company tables diagram

There are multiple person records for any contact. A classic many-to-one relationship.

  • A person can only belong to one contact.
  • A contact can have zero or more persons.

It is this relationship that drives the first to fields in the follow-up, sale, and document dialogs. Every time you select a new company, the person list below it has to be re-populated.

Person list

To get the list of persons under a contact:

SELECT * FROM person WHERE contact_id = 123 ORDER BY rank

Rows and entities

A ContactRow refers to a row in the contact database table. Therefore, it consists of basic data types supported by SQL.

The Rows type consists of a collection of rows such as ContactRows type consists of a collection of ContactRow types.

The ContactEntity represents a business object. It contains a set of properties bundled up as a single unit representing a particular business object. Entities contain properties of different data types such as properties of basic data types like int, string, boolean, entities, entity arrays, EntityElement, and LocalizedField.

๐Ÿ›ˆ Note
The Person property of the ContactEntity is a read-only Person item and not a PersonEntity.

Get contact entity

You can get a Contact entity either by using the classes provided in the entities layer or by using the agents in the services layer.

Create contact

Interests

Interest tab on Contact card -screenshot

Interests are stored on contacts and persons - there are two separate sets of interests and a separate set of link tables.

InterestLinkTable diagram

The link table (contactinterest) allows a single contact to have zero or more interests checked off.

The ContInt table is an MDO table, so interests can be grouped and organized under headings. The position under a heading does not matter to the linkage to a contact.

SELECT * FROM contint
ContInt_idnameranktooltipdeletedregisteredregistered_associate_id
854Hansa136Hansa028.10.2021 13.14:5994
855IFS137IFS028.10.2021 13.18:1794
856Agresso133Agresso028.10.2021 13.19:2394
857AS400134AS400028.10.2021 13.20:2294
SELECT * FROM contactinterest
contactinterest_idcontact_idcinterest_idxstartDateendDateflagsregistered
53459159431.12.2021 02:13:49028.10.2021 13.14:59
536401156931.12.2021 02:13:49028.10.2021 13.14:59
45770496531.12.2021 02:13:49028.10.2021 13.14:59
45259996531.12.2021 02:13:49028.10.2021 13.14:59

You can extend the list of interests for a contact by creating and adding a new interest to that list.

Contact cached value

The contact table has a counter field that stores the number of active interests. This field is used to cache the count. It is updated whenever the user edits the company. The field is used to quickly check whether the interests tab needs to indicate the presence of interests or not.

Interest code examples

Email and URL

To put together a list of the URLs and emails that belong to a contact:

SELECT * FROM url WHERE contact_id = 123 ORDER BY rank

SELECT * FROM email WHERE contact_id = 123 ORDER BY rank

There may be several URLs all referencing the same project_id. This is OK. The URLs will be presented in rank order. The first rank will always be 1.

These are simpler relationships than the owner ID + type relations used on phone and address.

CategoryList

The category list is used to classify a contact. The Contact.Category_id refers to an item on this list.

There are several methods of getting a category list:

๐Ÿ›ˆ Note
All list objects in the NetServer services API have a common interface. They can be accessed or modified using a ListAgent or an MDOAgent. The MDO agent provides a generic mechanism for reading lists. The List agent provides a strongly types API that is simpler to program with.

Explore the options and select the most appropriate method for your application. Consider using the CategoryCache.