+ Start a Discussion

SObject isQueryable()



   I have a custom Object Test__c and a User "Test User" with profile "Test Profile" which doesn't have access to this Object.


  I want to check if isQueryable() will work on this object.


 So i have done,



SObjectType objectType = Test__c.getSObjectType();

Schema.DescribeSObjectResult objectDescription = objectType.getDescribe();

System.debug('******OBJ ACC'+objectDescription.isQueryable());


if(objectDescription.isQueryable()) {


// If true Do some processing




Even though i dont have access to this object i am able to query it. Can any one let me know if i need to make any changes in the permissions or any thing else i am missing.






I think you are testing this for Admin that why you are able to find the permission on custom object. Try this with user (not admin) and that user profile doesn’t have permission of this object.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


I have a new User with Standard profile and i dont have access to that Object. In this case also i do get TRUE for isQueryable(). Can you give a try on ur org with just a sample object.





Make sure you use the "with sharing" keywords.


public with sharing YourClass {
   //class code