function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kmadminkmadmin 

Junction object involving User standard object and a custom object

My company has 60 branches across USA. Every user in Salesforce.com needs to be assigned to a branch. I have a custom object for branch that houses branch data (address, phone, fax, name, region etc). It looks like I am not able to add a lookup relationship in User as a custom field so that I can assign every user a branch.

 

So, what I thought I could do alternatively is link branches and users. I decided to create a junction object with two master detail relationships. One with user and second one with the Branch custom object.

 

However, l can't even do the junction object since the User object is not available in the drop-down list for master-detail relationship. I believe there must be some reason behind this design but this creates a problem for me.

 

Since the company keeps realigning branches and opening new ones, closing old ones etc all the time, creating a role hierarchy for 60 branches is not feasible.

 

How to best achieve what I need? Any help?

werewolfwerewolf

Actually you can make a lookup relationship to User.  You can't make a master-detail to User though.  So just make a lookup and you should be good to go.

 

Is there some particular reason why you need it to be a master-detail?

 

Incidentally, though, you'll notice that every custom object has an Owner field.  That means your Branch object has an Owner field which points to User (and Queue too) -- you could just set the relevant user in the Owner field of the branch too, if it's one to one.

Donovan KrugerDonovan Kruger

Due to the limitations and quirkiness of the User object, I suggest creating internal Contact records (recommend a separate Record Type) that correspond with each user.  You can then create the Master-Detail relationship you need, as well has have the convenient related lists from the Branch object to see all internal folks under that branch.

 

There are many other ways you can take advantage of having your users and/or employees in the system as Contact records.  Might as well start now.

kmadminkmadmin

Donovan,

 

Can you elaborate a bit further about  the internal users record type? Which object would I tie the record type to? I didn't quite get your reply but it looks interesting and might solve my problems.

Donovan KrugerDonovan Kruger

Sorry if I wasn't clear at first, but I suggest creating Contact records for each user.  First create an Account record for your own company, and then create the employees of your company as Contacts under that Account.  You would then create a Lookup relationship from Contact to your custom Branch object.

 

If you want to differentiate your company's Contact records from customer Contact records, I recommend creating a new Contact Record Type for Internal Contacts (or named as you like).  You could then have company-specific fields available for these internal contacts that wouldn't be applicable to customer contacts.  Creating record types assumes you have at least the Enterprise Edition of Salesforce.

 

Down the road, you may decide you want to use the Service and Support capabilities to handle internal issues within your company.  Since you will already have your users in the system as Contact records, you will be able to log Cases against them.  Yet another advantage to having your users/employees in the system as Contacts.

apexnetapexnet

Why use the contact record (with record type) instead of a custom object to do this?  

Thanks.