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
nickwick76nickwick76 

Possible to hide objects based on field values?

Hi, I am wondering if there is a way to hide opportunities or accounts or other objects for a user with a specific profile or role based on field values on the particular object?

 

Thanks / Niklas

Best Answer chosen by Admin (Salesforce Developers) 
BrendanOCBrendanOC

That sounds like  Criteria Based Sharing.  Vote for it here:

http://sites.force.com/ideaexchange/ideaSearchResults?q=criteria+based+sharing&cx=&cof=&c=09a30000000D9xt&s=criteria+based+sharing&searchType=c&thisSite.x=0&thisSite.y=0&thisSite=c

 

Currently, I don't think its possible without writing some customizations.  You can see if Apex Managed Sharing will meet your needs, or you could create a custom VisualForce UI with an Apex Class extension that adds your custom logic. 

 

You could also add a field to your records that specifies the sensitivity level of the record.  For example, Opportunity.sensitivity__c has values of {1, 2, 3}.  Based on the user's Role, Profile, or Group Membership you could create a SOQL query to only show records with a certain sensitivity level.

PseudoCode:

 

String SensitiveProfile  = '00exxxxxxxxxxx';

Profile ThisProfile = [select Name from Profile where Id = :userInfo.getProfileId()];

 

If (ThisProfile.Id == SensitiveProfile) {

 

List <Opportunities> Opps = [SELECT Name, Id, FROM Opportunities WHERE sensitivity__c = 3 LIMIT 100];

return Opps;

}

else {

// Access Denied

}

 

Of course that may be overkill.

 

Hope that helps!

All Answers

BrendanOCBrendanOC

That sounds like  Criteria Based Sharing.  Vote for it here:

http://sites.force.com/ideaexchange/ideaSearchResults?q=criteria+based+sharing&cx=&cof=&c=09a30000000D9xt&s=criteria+based+sharing&searchType=c&thisSite.x=0&thisSite.y=0&thisSite=c

 

Currently, I don't think its possible without writing some customizations.  You can see if Apex Managed Sharing will meet your needs, or you could create a custom VisualForce UI with an Apex Class extension that adds your custom logic. 

 

You could also add a field to your records that specifies the sensitivity level of the record.  For example, Opportunity.sensitivity__c has values of {1, 2, 3}.  Based on the user's Role, Profile, or Group Membership you could create a SOQL query to only show records with a certain sensitivity level.

PseudoCode:

 

String SensitiveProfile  = '00exxxxxxxxxxx';

Profile ThisProfile = [select Name from Profile where Id = :userInfo.getProfileId()];

 

If (ThisProfile.Id == SensitiveProfile) {

 

List <Opportunities> Opps = [SELECT Name, Id, FROM Opportunities WHERE sensitivity__c = 3 LIMIT 100];

return Opps;

}

else {

// Access Denied

}

 

Of course that may be overkill.

 

Hope that helps!

This was selected as the best answer
Dave007Dave007

Or I guess you could make every field hidden lets say for Accounts for that profile

 

You will not get rid of the ta/object unless you also make the tab hidden

Alex GroagAlex Groag
Hi - I know this is old, but I was able to do this by creating record types, page layouts, and workflows. This was done with OWD set to public read. This can be done much easier if you have OWD set to private, then you would share the object based on criteria. 

Based on your field value, the workflow will change the record type, which would be assigned to a page layout that does not have the have the hidden object under related lists. On top of that, the page layout for the hidden object would have all possible fields removed from the layout to hide as much of the information as possible and hide the tab.  This is a nutshell explaination, I'm happy to go into more detail if this is still an issue for people.