+ Start a Discussion
john8407john8407 

Coding to Override Sharing Rules

I know this sounds crazy, but I wasnt part of the setup of this org.  If the org wide rules are Private on Account and Contact, but you have a rule that extends it to some users.  Is there a way to write code that will make it private to some users?

 

Another scenario is if the account is shared as read only but contact is private, the user can still create a contact on that account.  Is there some type of coding that can disable or remove the New button on the contact related list of the account if the user is not the owner of the account? Basically allow read access to the account, but dont let them create contacts or anything on it but still let them have the ability to create based on their profile so they can on their accounts.

 

Im being told that it use to function like this but I dont see any code, the rule has been in place since the start and hasnt been modified but they say there was some coding that did this before? I dont beleive this is possible so I need everyones help here.

ngabraningabrani

John,

 

This can be done using Apex sharing rules. Basically you can allow additional access to certain users by writing Apex code. The following blog explain this -

 

http://astreait.com/wordpress/?p=26

 

Naveen

john8407john8407

I understand the apex sharing, you have to have a custom object created for it.  We dont have any custom objects for sharing.  Is there any other way?

ngabraningabrani

Apex sharing rules can be applied to both standard and custom objects.As an example for Account object, you can create an object with name AccountShare

 

The other way to allow access to records is by using Manual Sharing rules. These are available at Setup | Security Controls | Sharing Settings