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
Rinky ChawlaRinky Chawla 

How can we check if the code is running in WITH sharing context or WITHOUT sharing context in apex debug logs?

PriyaPriya (Salesforce Developers) 

Hi Rinky,

The best way is to check the class if it is using the keyword with/without sharing.

Regards,

Priya Ranjan

Suraj Tripathi 47Suraj Tripathi 47
Hi,
 
//Without haring apex code:-

public without sharing class noSharing {

// Code here

}

// With sharing apex code:-

public with sharing class sharingClass {

// Code here

}
Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi
    

 
Roxely MaiasRoxely Maias
The DreamHouse app
Let's think of a scenario. We'll use this scenario in the rest of this module to explore the many exciting tools and technologies offered by the Salesforce Platform(http://foxx99.com.br).