Giving a user access to 1 record on an object. - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Sam WardSam Ward 

Giving a user access to 1 record on an object.

I am creating a HR platform and I have been asked to ensure that only mangers can see everyones problems and that any user below can only see there own HR record and no-one else as it has or will have sensative information entred.

Is it possible to give access to a record on an object if that object has the users ID who is allowed to view this on it? (The record will not be created by them) 

I have never dealt with the permission side of things within Salesforce and from reading what I could I belive some of this may need to be code?

If anyone knows of any good sites, books, post which may help me acheive this it would be a massive help.
adam marksadam marks
Why not set the objects Organizational Wide Default to Private and then make the user who needs to see the record the owner of the record. That will do what you need to do. 
Mayank SrivastavaMayank Srivastava
Sam, this post has exactly what you need:

You need Apex Managed Sharing in order to accomplish this and there isn't a way (that I know of ) to do this declaratively. Now it might be possible using Process and Flows but I will have to try it out. If it works, this becomes the use case for my next blog post :)
Sam WardSam Ward

HI Adam, 

I could but there are email triggers from this we have  a prospect employee then convert this into an employee so everytime one is created it would just mean messing around, I did think of doing it like that and thank you for the input. 

Hi Mayank, 

I thought this was the case so I created a sandbox this morning for worse case sanario :( I will give it a good read tonight and give it ago, if you come up with anything else would be great to hear. 

Thanks guys! 


Martin KeatingMartin Keating
What about using manual sharing? You could auto assign a task to the employee's manager upon convert that reminds them to manually share the record to that employee. I know it is a manual step, but it's relatively simple and doesn't require code. It could depend on your company.
Tom BlamireTom Blamire
I would set the object to Private and then use cirteria based sharing rules to expose the data to the relevant managers. From here, the manager can use manual sharing to expose records to others if need be 
Tom BlamireTom Blamire
If you are using Role Hierarchy then this will work also
Ines GarciaInes Garcia
Hi Sam,

If you are looking for resources to get you started with sharing, have a look to theses:

1. Data Sharing Module in trailhead:

2. Salesforce Sharing 'cheatsheet' -

Always keep in mind, the most restrictive is to be set in Orgwide Defaults. Set up > Sharing edit your object.
       Then sharing rules on your object can open up access to groups (public, roles etc)
              If is on adhoc basis, a particular record to a particular user, then the answer is manual sharing. (button on record, can be done by record owner or above in role hierarchy)

Hope this helps :)

Ines GarciaInes Garcia
Hi Sam, 

Hope the answers helped, if so could you please select one of the responses as 'Best Answer'?

The selected 'Best Answer' is used to highlight the response to your question that has helped the most, so that when someone else looks at similar questions in the future quickly can identify the answer :)

Otherwise do let us know where are you at if we could help further?
Mayank SrivastavaMayank Srivastava
Sam, I was able to do this using Process and Flows and here's my blog post explaining the solution step by step:

It might need a few tweaks depending upon your exact use case but the premise is the same. Good luck and happy holidays!