Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Company Relationship - need to understand the logic of this Contact/Company relationship please !


Recommended Posts

Hi all, I'm trying to figure out how to create a one-to-many relationship for my Contacts' employers (many employee's / 1 company)?

I'm assuming that I need to have a separate table for my Contacts, & another for "Companies"?

And by entering the name of the Company in my contacts layout, a record would be created in my "Companies" table.

I'm confused by how to set up the relationships, so that only One Company is created, but shows [via a portal in my Companies layout], all employees.

Currently, each time I enter the [same] company name, a new record is being created - leading to multiple records for the same company. So if John's employer is XYZ LLC, and Pete's employer is also XYZ LLC, 2 records are created and not just one.

Any help for this newbie, is greatly appreciated.

Link to post
Share on other sites
AHunter3

Do your data entry from a Company layout, not a Contacts layout.  Use the portal to Contacts on the Company layout to make multiple Contacts for each Company.  In your relationship, make sure you have the box marked "allow creation of records in this table via this relationship" checked on the Contacts side.

Link to post
Share on other sites

OK thanks, but to confirm, am I using the Primary key in Contacts to Foreign Key in Company table? Or Company Fields connected in both etc?

Thanks

Link to post
Share on other sites

Hmmm, it works, sort of . . .  but not exactly how I wanted it to work as it means entering all employees via the Company layout/Contacts portal. Some of the contacts are not associated with companies.

I'd like to be able to enter a new contact in the Contact layout, but show the company name and all employees of that company in a portal within the Contact layout.

Is this possible?

Link to post
Share on other sites
AHunter3

Yeah, you can do it that way.  You can make a dropdown value list for Contacts::ForeignKey, containing all values of Company::PrimaryKey, "also showing values from" Company::CompanyName and (if you want) displaying only the CompanyName values (so that that is what you see when you click -- the name of the company you're picking, not it's number).  So to make a new Contact, you make a new blank record, pick what company from the dropdown, then type in the person's name and all that stuff.

It requires that you input all the Companies first, or else that you stop what you're doing (if the company in question isn't already in the system) and go over to the Companies layout and enter the missing company.

 

This does let a Contact be unassociated with any company (just leave the foreign key field blank).

 

Link to post
Share on other sites
  • Gold Members
Michael Rocharde

To show all the contacts for the same company as the record you are in, you need to create a self-join from the current Contacts table occurrence to another table occurrence of Contacts; let's call it SJ_CompanyContacts. You connect the two using the CompanyID field. In the portal itself, you make the name field uneditable and set it as a button to go to all Related records for the portal relationship. So when you click on a name, you go to that record but you still see all the same contacts in the portal. (I always use conditional formatting on the name field so that if it's ID matches the ID of the record, you are in, the field is reversed out. This makes it obvious which record you are looking at in th portal. You can, if you wish extend the relationship by using a 2nd criteria where the contactID is not equal to (≠) the ContactID. This means that you will see, in the portal, all other contacts for the same company but not the one you are currently in.

HTH

 

Michael Rocharde

Link to post
Share on other sites
On 9/16/2020 at 8:32 AM, AHunter3 said:

Yeah, you can do it that way.  You can make a dropdown value list for Contacts::ForeignKey, containing all values of Company::PrimaryKey, "also showing values from" Company::CompanyName and (if you want) displaying only the CompanyName values (so that that is what you see when you click -- the name of the company you're picking, not it's number).  So to make a new Contact, you make a new blank record, pick what company from the dropdown, then type in the person's name and all that stuff.

It requires that you input all the Companies first, or else that you stop what you're doing (if the company in question isn't already in the system) and go over to the Companies layout and enter the missing company.

 

This does let a Contact be unassociated with any company (just leave the foreign key field blank).

 

Thats what I was looking for AHunter3 . . . thanks.

Link to post
Share on other sites

Michael,

Also very helpful information - I'll see if I can work through this in a copy of my current database so I don't screw things up. I'm sure I'll have a few more questions about this so will get back to you once I have them. 

Thanks

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use