+ Start a Discussion
thsfthsf 

Data Modeling - Associating a Contact and an Account to a Custom Object

I have a custom object that I want to be associated to a Contact (via a Lookup field), but I also want to be strongly tied to the Contact's Account.  What is the best way to do this?

 

I understand that I can access the Contact's Account information via a relationship query, but I can see benefits to adding a 2nd lookup field for the Account.  For example, this would give me the ability to add a related list to the Account layout displaying the custom objects.

 

I see similarities between my situation and the standard Salesforce Case object has lookups for both the Account and Contact.

 

I am looking for suggestions on the right way to do this.  Should I create a trigger that defaults the associated Account when a Contact is set?  Should I filter the Contact lookup by the associated Account?  Should I use a single Contact lookup field and use relationship queries to access the associated Account?

 

Thanks in advance.

Best Answer chosen by Admin (Salesforce Developers) 
TrimbleAgTrimbleAg

Danan, 

 

So I created my own Entitlements custom object, and I have it as the account is the parent and the contact is just a standard lookup, and I like it a lot, just like you stated, having the related list is good to have.

 

And if your worried about accounts being entered that dont match the contacts entered, just through a related lookup filter on it.

 

Thanks my advice atleast!

 

PB

All Answers

TrimbleAgTrimbleAg

Danan, 

 

So I created my own Entitlements custom object, and I have it as the account is the parent and the contact is just a standard lookup, and I like it a lot, just like you stated, having the related list is good to have.

 

And if your worried about accounts being entered that dont match the contacts entered, just through a related lookup filter on it.

 

Thanks my advice atleast!

 

PB

This was selected as the best answer
thsfthsf

I added both the Account and Contact lookup fields and think it works nicely.  I then added the a filter on the Contact field and think that works really nice.  From a user's perspective, there is an extra click to lookup the Account first, but that results in the filtering of the Contact list which is actually quite nice.