Hi, In this post, I will give a brief description of Request class with sample code that help you to find running context of apex in salesforce.
Get the current apex context
In salesforce, Request class helps you to achieve this task, following properties are present in request class,
1. getCurrent() - provide current request object that contains the request Id and quiddity value.
2. getQuiddity() - This function provides the quiddity value of the current request object like ANONYMOUS, BATCH_APEX or FUTURE based on context.
3. getRequestId() - This function helps to get identifier of request of the current request object
Example: Execute the following code through anonymous window
Request reqInfo = Request.getCurrent();
String currentRequestId = reqInfo.getRequestId();
Quiddity objQuiddity = reqInfo.getQuiddity();
System.debug('currentRequestId '+objQuiddity);
System.debug('Quiddity '+objQuiddity);
Output:
Hope you like this post, for any feedback or suggestions please feel free to comment. I would appreciate your feedback and suggestions.
Thank you.
0 Comments
Post a Comment