Salesforce Fact #943 | Get execution context using Quiddity Enum

Sometimes we need to know the context of the execution event of the apex code, whether it is called from UI, anonymous window, data load, batch apex etc.

System class provides a Quiddity enum with all the possible values of execution contexts. It can be figured out by calling System.Request.getCurrent().getQuiddity().

For example,

If the apex code is invoked from the anonymous window, it returns ANONYMOUS.

If the apex code is invoked from any data load using import wizard or Data loader(with Bulk API enabled), it returns BULK_API.

Comments

Popular posts from this blog