+ Start a Discussion
craigmhcraigmh 

View All Data permission on object

I have a custom object that I'm developing with. Is there any way to test in Apex whether or not the current user has the View All Data permission on this custom object alone, not the organization-wide one?

Damien_Damien_

I'm not 100% sure.  I know you can find out if the User has access to a specific field.  I need to learn more about the Schema global methods, but if there is a way to find that out it'll be in the Schema methods somewhere.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_schema.htm#datacategory

 

There is a lot to them and they're a little confusing.  Good luck unless someone can find you a more specific answer.  Sorry for the generality of this.

Damien_Damien_

Actually, I may have just found your answer.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject_describe.htm

 

There is an isAccessible method and isSearchable and isQueryable.  I'm sure there is some combination or single one here that will give you what you need.

craigmhcraigmh

Yeah, that's the first place I looked. Unfortunately, I didn't really find much for this. I know that the users have access to the fields that they need to, it's just the records...

 

To give a little more detail, I have a custom object with columns used for filtering. I then use dynamic SOQL to filter based upon the data in these columns. If the user has View All Data either organization-wide, or just on the custom object, I want to bypass the filters.

craigmhcraigmh

"Returnstrue if the current user can see this field,false otherwise"

 

I hope they mean "object", not "field."

Damien_Damien_

Haha, The copy/paste monster strikes again!

craigmhcraigmh

I think that, like with most Salesforce problems, the solution is to do something completely different.

 

Like adding a checkbox field to the User object...

Damien_Damien_

That could work also.... only thing is that it adds an extra manual step that the Users would need trained to do.  Which may not be a big deal depending on the audience.