You need to sign in to do that
Don't have an account?
Running class Id in apex
Hi Team,
Like we have System class method currentPageReference() to get the reference of current VFPage, do we have something similar to get the details of running apex class?
My requirement is to check status of previous instance of my Batch class when it ran last time. Depending on that I need to set certain attributes of current instance.
Currently I am storing Batch Class Id in custom setting and referring that while querying AsyncApexJob for status. Just wondering if there any other way.
Like we have System class method currentPageReference() to get the reference of current VFPage, do we have something similar to get the details of running apex class?
My requirement is to check status of previous instance of my Batch class when it ran last time. Depending on that I need to set certain attributes of current instance.
Currently I am storing Batch Class Id in custom setting and referring that while querying AsyncApexJob for status. Just wondering if there any other way.
I think, You can use ApexClass object in soql to get class id.
Current class name, you can identify by hardcoding the string variable in class, or try below snippet to provide it dyanamically -
String CurrentClassName =String.valueOf(this).substring(0,String.valueOf(this).indexOf(':'));
'this' will provide the current instance of class.
Hope it is helpful !!☺
All Answers
I think, You can use ApexClass object in soql to get class id.
Current class name, you can identify by hardcoding the string variable in class, or try below snippet to provide it dyanamically -
String CurrentClassName =String.valueOf(this).substring(0,String.valueOf(this).indexOf(':'));
'this' will provide the current instance of class.
Hope it is helpful !!☺
I am trying to avoid SOQL.