Get the current apex context at run time salesforce - Salesforce Globe For You
Solution: Use the getCurrent(),getQuiddity() and getRequestId() methods of Request class to know the currrent apex context.
getQuiddity() returns a value such as ANONYMOUS or BATCH_APEX or FUTURE based on context.
Example: Run below code from Execute Anonymous window
Request objRequest = Request.getCurrent();
Quiddity objQuiddity = objRequest.getQuiddity();
system.debug('Quiddity'+objQuiddity);
The debug returns ANONYMOUS as the current context is Execute Anonymous window.
Output:
No comments:
Post a Comment