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
Bramha1Bramha1 

SObject isQueryable()

Hello,

 

   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.

 

Thanks

Reddy

Navatar_DbSupNavatar_DbSup

Hi,


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. 

Bramha1Bramha1

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.

 

Thanks

reddy

craigmhcraigmh

Make sure you use the "with sharing" keywords.

 

public with sharing YourClass {
   //class code
}