Is there any OOTB way of having a Primary Contact for an Account?
One idea is to create a custom lookup field for Primary Contact on Account object. However, it will need validation such as the selected primary Contact’s Account should match the currently viewing Account. (I do not want to use a Lookup Filter because users can click Show All Records
.)
- Will I need to utilize
AccountContactRole
for my requirement? If yes, how should I implement this junction object to fulfil my requirement? - Or should I go with my Lookup field with a Validation Rule?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Any special reason why you need a custom lookup field on Account? That’s what AccountContactRole object is for (as you mentioned in the question).
It’s a junction object though (has 2 masters) which means you can’t make a lookup to it (similar to OpportunityContactRoles, OpportunityLineItems etc).
If you need it really as lookup (to use in some formulas I guess?) consider filling it in with a trigger or something (based on Contact Roles), not letting users pick it. Filtered lookups are bit annoying for users as they’d need to know what to type in the search or view the Contact before using the lookup (so it appears on their “Recently viewed” in the lookup window).
Here’s the out of the box functionality (sample data found in any Developer Edition):
- Not all Contacts need to have a Role. Contact can have more than 1 Role. Only one can have “Primary” ticked (if you set it, SF will automatically remove it for you from all others, even if you’ll try to cheat with a mass update from Apex or Data Loader for example).
- Contacts that aren’t related to this company can be selected too (imagine a company that has HQ office, a branch office and common accounting department – you could use person from HQ Accounting as a Role in the child company).
- You can modify the Roles picklist in the setup. You can’t add fields to the object or make lookups to it. As far as I know there’s no “magic” happening when you make an Opportunity (if you’d want to automatically copy this data to Opportunity Contact Roles you’d need a trigger. But since each Opp should be unique and could have different key stakeholders maybe it’s good).
I think that’s pretty much it, check help for more? Not sure what more “out of the box” you’d want that would be generic enough to work OK for all businesses…
Last but not least – Entity Relationship Diagram 🙂
Method 2
Edit:
You changed your question, and i’m going with eyescream here, Contact Roles are the best method to go with, instead of using a lookup filter.
For future reference, here is the answer on the lookup filter question:
Change your Lookup filter, to set the Account of the contact, equal to that of the current account. Put the filter on required, that way, they won’t be able to select Show All Records
, and only the contacts of the current account will be shown.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0