Posts

Sharing Keyword in Salesforce

Background:- Before I start with Sharing keyword and its importance, I would like to discuss in brief about UserMode and SystemMode. As main reason for using sharing keyword depends on the usage of Usermode and SystemMode. UserMode:- User mode is nothing but apex code running by respecting user's permissions and sharing of records. For example, logged in user does not have create permission and so he/she is not able to create a record.In Salesforce, only standard controllers and anonymous blocks like developer console run in user mode. SystemMode:-System mode is nothing but running apex code by ignoring user's permissions. For example, logged in user does not have create permission but he/she is able to create a record. We can think of SystemMode as GodMode, Apex code has access to all objects and fields— object permissions, field-level security, sharing rules aren't applied for the current user. This is to ensure that code won’t fail to run because of hidden fields or...

Queueable Apex in Salesforce

e Apex in Salesforce The class which implements the  Queueable  interface are basically called as  Queueable  apex class. This interface enables you to add jobs to the queue and monitor them, which is an enhanced way of running your asynchronous Apex code compared to using future methods. The interface has only one method execute which takes the parameter of  QueableContext . For Apex processes that run for a long time, such as extensive database operations or external Web service callouts, you can run them asynchronously by implementing the  Queueable  interface and adding a job to the Apex job queue. In this way, your asynchronous Apex job runs in the background in its own thread and doesn’t delay the execution of your main Apex logic. Each queued job runs when system resources become available. A benefit of using the  Queueable  interface methods is that some governor limits are higher than for synchronous Apex, such as heap siz...