Sometimes it is required to find out current API version of your Org (Sandbox/Dev Org/Production) in order to perform some operations like making HTTP request to SFDC URI which contains api version.
As of now, I was not able to find any method in apex through which I can get my org current api version So I have created utility class which uses Tooling API to get all version related to org and returning latest/current api version like 39.0,40.0 etc.
Below is complete code for this.
You can run below scripts in developer console to get current API version after saving above class in your org.
Decimal currentAPIVersion = UtilityClassForSFDC.findAPIVersionOfOrg();
system.debug('***************currentAPIVersion:'+currentAPIVersion);
After running you may get "Unauthorized endpoint url". Just add your SFDC base URL in remote site setting to avoid this exception.
Hope this will help!!!
Looking forward for your comments and suggestions..
DYNAMIC APEX IN SALESFORCE
SOQL INJECTION IN SOQL
CUSTOM METADATA AND CUSTOM SETTINGS IMPLEMENTATION TRICKS
SMART TABLE USING ANGULARJS IN VISUALFORCE PAGE
REST API TUTORIAL FOR SALESFORCE
VISUALFORCE COMPONENT FOR RECORD STATUS BAR
FETCHING FILE FROM EXTERNAL/PUBLIC URL AND STORING IT IN SALESFORCE
As of now, I was not able to find any method in apex through which I can get my org current api version So I have created utility class which uses Tooling API to get all version related to org and returning latest/current api version like 39.0,40.0 etc.
Below is complete code for this.
You can run below scripts in developer console to get current API version after saving above class in your org.
Decimal currentAPIVersion = UtilityClassForSFDC.findAPIVersionOfOrg();
system.debug('***************currentAPIVersion:'+currentAPIVersion);
After running you may get "Unauthorized endpoint url". Just add your SFDC base URL in remote site setting to avoid this exception.
Hope this will help!!!
Looking forward for your comments and suggestions..
More Blogs>>:
USING DATABASE.UPSERT WITH EXTERNAL ID
DYNAMIC APEX IN SALESFORCE
SOQL INJECTION IN SOQL
CUSTOM METADATA AND CUSTOM SETTINGS IMPLEMENTATION TRICKS
SMART TABLE USING ANGULARJS IN VISUALFORCE PAGE
REST API TUTORIAL FOR SALESFORCE
VISUALFORCE COMPONENT FOR RECORD STATUS BAR
FETCHING FILE FROM EXTERNAL/PUBLIC URL AND STORING IT IN SALESFORCE
Hi There,
ReplyDeleteThis is indeed great! But I think perhaps you are generally referring How to find Salesforce API version of your Org in Apex which is getting unsustainable.
I have an apex datatable returning some User fields from a list in my apex class. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. I can run the SOQL in my class but I'm not sure how to get the correct result per user into the table, i.e. how to put it into the correct row and column in my table. Can I attach this $amount to each user without creating a custom field?
I am so grateful for your blog. Really looking forward to read more.
Kind Regards,
Preethi.
Thank you for this!! Works great for building callouts in my org :)
ReplyDelete