Where is Vendor Primary Contact stored in the database?

How do I find which vendor contact record is the main vendor contact in the database? There isn’t a field called main contact? How does Epicor keep track of this and how can I query to find out which contact is the main one? Either BAQ or more preferable in an SQL query against the database.

Look at the Vendor.PrimPCon field.

Thank you that was the ticket. It’s interesting to note that VendCnt is keyed to the Vendor table by VendorNum and ContactID. Here’s the final query to get the main vendor contact

SELECT v.VendorID, v.[Name], v.VendorNum, 
       vc.[Name] AS mainContact, vc.EmailAddress AS mainContactEmail
FROM [Dbo].[Vendor] AS v
INNER JOIN [Erp].[VendCnt] AS vc
          ON v.VendorNum = vc.VendorNum
          AND v.PrimPCon = vc.ConNum
WHERE v.VendorID = 'somevendorid'    -- this is the vendor info dynamically inserted
AND vc.PurPoint = '' -- not interested in purchase point contacts so this clause is necessary to remove those records
1 Like

@smason Can you mark the solution for future generations :slight_smile:

1 Like

This post solved my problem 3 years later!

It would appear the Vendor.PrimPCon lists the VendorCnt.ConNum of the contact who has the box checked. Ex: If the Contact for which the Primary Contact box checked is ‘3’ (Value of VendorCnt.ConNum) then Vendor.PrimPCon will return 3.

Further fun: Vendor.PrimPCon will return 0 (zero) if no contact is flagged as the Primary Contact.

For those who dabble in queries but can’t read SQL code, I’ve attached a picture of a join I’ve done in a BAQ. The result pulls a table of all the primary contacts.

1 Like