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
Pradeep Satpute 8Pradeep Satpute 8 

Want to check access on object for the user

 if(usr.Division =='TURF'){
                List<user>samelineofBuisnessUsers=[SELECT Id,email FROM User WHERE IsActive = true AND(Division =:usr.Division) AND(Id !=:usr.Id)];
                for(user samedivuser : samelineofBuisnessUsers){
                    sendTo.add(samedivuser.email);
                }
Hi In above code i want to add those user email in sendTo who has access on special Price object.please help how i can implement this
VinayVinay (Salesforce Developers) 
Hi Pradeep,

You can use the Schema Class to check permission.
Check the Object Permission:
if(Schema.sObjectType.Contact.isAccessible()) {
}
To Check the Field Permission:
if (Schema.sObjectType.Contact.fields.Email.isAccessible()) {Contact c = [SELECT Email FROM Contact WHERE Id= :Id];
https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_fields_describe.htm?search_text=isAccessible

Please mark as Best Answer if above information was helpful.

Thanks,
Pradeep Satpute 8Pradeep Satpute 8
Hi vinay,
i dont want to check current user permision.I want to check the user which are samelineofBuisnessUser in this list.if they have access then only they will receive email