Wednesday, October 26, 2016

Access salesforce API version of a class in Apex

This can be achieved by using following steps
1. Login to your sandbox.
2. Go to Developer Console.
3. Go to Debug menu and click on Open Execute Anonymous Window
4. Paste the following code in that window.
ApexClass apexClass = [
  SELECT ApiVersion
  FROM ApexClass
  WHERE Name = 'YourClass Name'
];
System.debug(apexClass.ApiVersion);
5.Run this code.
6. This will print the  API version of your Apex class.