Where is Apex used?
The following table lists the types of execution contexts the Apex code can run from and considerations with respect to security and state management. While a description of how to implement each of these is outside the scope of this book, some aspects such as batch Apex are discussed in more detail in a later chapter when considering data volumes.
Execution context |
Security |
State management |
---|---|---|
Anonymous Apex |
Sharing is enforced by default, unless disabled by applying the CRUD and FLS are enforced by default, but only against the code entered directly into the Execute Anonymous window. The code will fail to compile if the user does not have access to the objects or fields referenced. Note that the checking is only performed by the platform at compilation time; if the code calls a pre-existing Apex class, there is no enforcement within this class and any other class it calls. |
See Note 2. |
Apex Controller action method | ... |