W039: Link contact to entity
Associates an existing contact with a customer, vendor, or other entity. Triggered from Customer Detail or Vendor Detail, "Add contact" with an existing contact.
Steps
-
Verify the contact exists. Call
Contacts.getContactById. -
Verify the entity exists. Route through the owning component (
Customers.getCustomerById,Vendors.getById, etc.) based onentityType. The Contacts component will not resolve this on its own; it has noentity_idforeign key. -
Insert the link. Call
Contacts.linkToEntity({ contactId, entityType, entityId, role, notes }).
Returns
The new link row.
Business rules
- Entity resolution is L3's job. The Contacts component intentionally does not know how to resolve an
entity_idback to its source table; the workflow routes perentityType.
Errors
NotFoundError. The contact or the entity was not found.